https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81054
Bug ID: 81054 Summary: [7/8 Regression] ICE with volatile variable in constexpr function Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: error-recovery, ice-on-invalid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: reichelt at gcc dot gnu.org Target Milestone: --- The following invalid code snippet (compiled with -std=c++1z) triggers an ICE since GCC 7.1.0: ================================== struct A { volatile int i; constexpr A() : i() {} }; struct B { static constexpr A a {}; }; ================================== bug.cc:9:25: error: the type 'const A' of constexpr variable 'B::a' is not literal static constexpr A a {}; ^ bug.cc:1:8: note: 'A' is not literal because: struct A ^ bug.cc:3:16: note: non-static data member 'A::i' has volatile type volatile int i; ^ bug.cc:9:22: error: in-class initialization of static data member 'const A B::a' of non-literal type static constexpr A a {}; ^ bug.cc:9:25: internal compiler error: in make_rtl_for_nonlocal_decl, at cp/decl.c:6427 static constexpr A a {}; ^ 0x684049 make_rtl_for_nonlocal_decl ../../gcc/gcc/cp/decl.c:6425 0x6abdda cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ../../gcc/gcc/cp/decl.c:7092 0x6ca9ee grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*, bool, tree_node*, tree_node*) ../../gcc/gcc/cp/decl2.c:956 0x752dbd cp_parser_member_declaration ../../gcc/gcc/cp/parser.c:23421 0x753a3a cp_parser_member_specification_opt ../../gcc/gcc/cp/parser.c:22958 0x753a3a cp_parser_class_specifier_1 ../../gcc/gcc/cp/parser.c:22111 0x755f31 cp_parser_class_specifier ../../gcc/gcc/cp/parser.c:22363 0x755f31 cp_parser_type_specifier ../../gcc/gcc/cp/parser.c:16449 0x768e21 cp_parser_decl_specifier_seq ../../gcc/gcc/cp/parser.c:13353 0x770e01 cp_parser_simple_declaration ../../gcc/gcc/cp/parser.c:12678 0x771cf5 cp_parser_block_declaration ../../gcc/gcc/cp/parser.c:12625 0x744584 cp_parser_declaration ../../gcc/gcc/cp/parser.c:12523 0x779b2b cp_parser_declaration_seq_opt ../../gcc/gcc/cp/parser.c:12399 0x779e0a cp_parser_translation_unit ../../gcc/gcc/cp/parser.c:4364 0x779e0a c_parse_file() ../../gcc/gcc/cp/parser.c:38475 0x8ba5b6 c_common_parse_file() ../../gcc/gcc/c-family/c-opts.c:1104 Please submit a full bug report, [etc.]