https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67333
Mikhail Maltsev <miyuki at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |miyuki at gcc dot gnu.org --- Comment #1 from Mikhail Maltsev <miyuki at gcc dot gnu.org> --- EDG accepts the first testcase. The second one is rejected, but presumably due to incomplete C++14 support. In potential_constant_expression_1 we have a check: if (TREE_THIS_VOLATILE (t)) { if (flags & tf_error) error ("expression %qE has side-effects", t); The comment in tree.h says: /* Nonzero means this expression is volatile in the C sense: its address should be of type `volatile WHATEVER *'. In other words, the declared item is volatile qualified. ... If this bit is set in an expression, so is TREE_SIDE_EFFECTS. */ In our case t is: (gdb) p t $10 = <var_decl 0x7ffff66a7cf0 meow> (gdb) pt warning: Expression is not an assignment (and might have no effect) <var_decl 0x7ffff66a7cf0 meow type <array_type 0x7ffff6800c78 type <integer_type 0x7ffff6800a80 int volatile type_6 SI size <integer_cst 0x7ffff66bd0a8 constant 32> unit size <integer_cst 0x7ffff66bd0c0 constant 4> align 32 symtab 0 alias set -1 canonical type 0x7ffff6800a80 precision 32 min <integer_cst 0x7ffff66bd060 -2147483648> max <integer_cst 0x7ffff66bd078 2147483647> pointer_to_this <pointer_type 0x7ffff6800d20>> TI size <integer_cst 0x7ffff669bea0 constant 128> unit size <integer_cst 0x7ffff669beb8 constant 16> align 32 symtab 0 alias set -1 canonical type 0x7ffff6800c78 domain <integer_type 0x7ffff6800b28 type <integer_type 0x7ffff669f1f8 sizetype> type_6 DI size <integer_cst 0x7ffff669be58 constant 64> unit size <integer_cst 0x7ffff669be70 constant 8> align 64 symtab 0 alias set -1 canonical type 0x7ffff6800b28 precision 64 min <integer_cst 0x7ffff669be88 0> max <integer_cst 0x7ffff680adc8 3>> pointer_to_this <pointer_type 0x7ffff68133f0>> side-effects addressable volatile used tree_1 decl_5 TI file /home/miyuki/gcc/test/meow/meow.cc line 15 col 18 size <integer_cst 0x7ffff669bea0 128> unit size <integer_cst 0x7ffff669beb8 16> align 32 context <function_decl 0x7ffff67ffe00 main>> I.e. the condition is probably wrong and we should also check that t is an expression, not a declaration.