https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83273
Bug ID: 83273 Summary: if constexpr does not fail with run-time conditions Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nico at josuttis dot de Target Milestone: --- The following C++17 program should not compile, but it does: #include <iostream> int main() { auto d = 42; if constexpr (d > 0) { std::cout << "oops \n"; } } This even works inside a loop over different values of d. And I found it trying this: if constexpr (auto obj = 42; obj == 0) { //... } which should need a const/constexpr in the if initialization. Reported as recommended by Jonathan Wakely. Might also be a problem in 7.x