Sample reproducer: """ #include <vector> int main() { std::vector<int> bits(128, 1); const std::size_t errorCount = 0; // constexpr std::size_t errorCount = 0; if (errorCount != 0) // if constexpr (errorCount != 0) { for (std::size_t i = 0; i < bits.size(); i += bits.size() / errorCount) { bits[i] = 0; } } } """ Will error with -Wall -Wextra -Werror. Issue happens with 4.1.2 and newer. """" <source>: In function 'int main()': <source>:9:67: error: division by zero [-Werror=div-by-zero] 9 | for (std::size_t i = 0; i < bits.size(); i += bits.size() / errorCount) | ~~~~~~~~~~~~^~~~~~~~~~~~ cc1plus: all warnings being treated as errors Compiler returned: 1 """
I've opened an upstream PR for it: https://gcc.gnu.org/PR110464 Clang handles it correctly, so perhaps we should too.