https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96742
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- Oh and since C++17 you can do: if constexpr (N != 0) for (size_t i = 0; i < N; ++i) { ret += i * x[i]; } but it still shouldn't be necessary :-)