diff --git a/src/archive/ArchiveList.cxx b/src/archive/ArchiveList.cxx index 5c1344a0a..25a4a72f9 100644 --- a/src/archive/ArchiveList.cxx +++ b/src/archive/ArchiveList.cxx @@ -43,8 +43,12 @@ const ArchivePlugin *const archive_plugins[] = { nullptr }; +static constexpr std::size_t n_archive_plugins = std::size(archive_plugins) - 1; + /** which plugins have been initialized successfully? */ -static bool archive_plugins_enabled[std::size(archive_plugins) - 1]; +/* the std::max() is just here to avoid a zero-sized array, which is + forbidden in C++ */ +static bool archive_plugins_enabled[std::max(n_archive_plugins, std::size_t(1))]; #define archive_plugins_for_each_enabled(plugin) \ archive_plugins_for_each(plugin) \ diff --git a/src/input/Registry.cxx b/src/input/Registry.cxx index 6fd2fe424..f5a37f2a1 100644 --- a/src/input/Registry.cxx +++ b/src/input/Registry.cxx @@ -83,7 +83,11 @@ const InputPlugin *const input_plugins[] = { nullptr }; -bool input_plugins_enabled[std::size(input_plugins) - 1]; +static constexpr std::size_t n_input_plugins = std::size(input_plugins) - 1; + +/* the std::max() is just here to avoid a zero-sized array, which is + forbidden in C++ */ +bool input_plugins_enabled[std::max(n_input_plugins, std::size_t(1))]; bool HasRemoteTagScanner(const char *uri) noexcept