https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65327
Bug ID: 65327 Summary: GCC rejects "constexpr volatile int i = 5;" Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Casey at Carter dot net See http://stackoverflow.com/questions/28883510/can-constexpr-be-combined-with-volatile for discussion. GCC 5 (Identified as "5.0.0 HEAD 20150304" on Wandbox at http://melpon.org/wandbox/permlink/u7BC3wFEfMv0zrVN) rejects this program: int main() { constexpr volatile int i = 5; } with the diagnostic: prog.cc: In function 'int main()': prog.cc:3:28: error: both 'volatile' and 'constexpr' cannot be used here constexpr volatile int i = 5; AFAICT, this program is well-formed: `constexpr` can be applied to literal types, which includes scalar types, which includes cv-qualified arithmetic types. Semantically, I *think* "constexpr volatile" is equivalent to "const volatile" since "constexpr" objects are implicitly "const" but lvalue-to-rvalue conversions applied to volatile glvalues cannot be part of a core-constant-expression.