https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86327
Bug ID: 86327 Summary: Spurious error on non-constant expression in constexpr function Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Reduced example from https://stackoverflow.com/q/51053280/2069064: int global = 0; constexpr int f(bool arg) { if (arg) { return 1; } return global++; } Fails on gcc trunk with: <source>: In function 'constexpr int f(bool)': <source>:8:1: error: the value of 'global' is not usable in a constant expression } ^ <source>:1:5: note: 'int global' is not const int global = 0; ^~~~~~ Compiler returned: 1 But the function is fine. The near-equivalent formulation of constexpr int g(bool arg) { if (arg) { return 1; } else { return global++; } } also compiles fine.