https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85061
Bug ID: 85061 Summary: ICE with __builtin_offsetof applied to static member Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: 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 triggers an ICE since GCC 4.0.0 (when __builtin_offsetof was introduced): ================================================= struct A { static int x[2]; }; int i = __builtin_offsetof(volatile A, x[0]); ================================================= bug.cc:6:44: internal compiler error: in fold_offsetof_1, at c-family/c-common.c:6275 int i = __builtin_offsetof(volatile A, x[0]); ^ 0x67d2bf fold_offsetof_1(tree_node*, tree_code) ../../gcc/gcc/c-family/c-common.c:6275 0xa2d34a fold_offsetof(tree_node*) ../../gcc/gcc/c-family/c-common.c:6290 0x925d4d cp_parser_builtin_offsetof ../../gcc/gcc/cp/parser.c:9899 0x925d4d cp_parser_primary_expression ../../gcc/gcc/cp/parser.c:5398 0x937c0c cp_parser_postfix_expression ../../gcc/gcc/cp/parser.c:7032 0x9387e0 cp_parser_unary_expression ../../gcc/gcc/cp/parser.c:8324 0x9186df cp_parser_cast_expression ../../gcc/gcc/cp/parser.c:9092 0x918eea cp_parser_binary_expression ../../gcc/gcc/cp/parser.c:9193 0x91a724 cp_parser_assignment_expression ../../gcc/gcc/cp/parser.c:9488 0x91987b cp_parser_constant_expression ../../gcc/gcc/cp/parser.c:9772 0x91a6a7 cp_parser_initializer_clause ../../gcc/gcc/cp/parser.c:21929 0x91cf62 cp_parser_initializer ../../gcc/gcc/cp/parser.c:21869 0x93c3ae cp_parser_init_declarator ../../gcc/gcc/cp/parser.c:19684 0x943758 cp_parser_simple_declaration ../../gcc/gcc/cp/parser.c:13059 0x944568 cp_parser_block_declaration ../../gcc/gcc/cp/parser.c:12884 0x9484c2 cp_parser_declaration ../../gcc/gcc/cp/parser.c:12782 0x9488d1 cp_parser_declaration_seq_opt ../../gcc/gcc/cp/parser.c:12658 0x948bc4 cp_parser_translation_unit ../../gcc/gcc/cp/parser.c:4563 0x948bc4 c_parse_file() ../../gcc/gcc/cp/parser.c:39024 0xa480d6 c_common_parse_file() ../../gcc/gcc/c-family/c-opts.c:1132 Please submit a full bug report, [etc.]