https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88383
Bug ID: 88383 Summary: ICE calling _builtin_has_attribute(r, aligned(N))) on an overaligned reference r Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- While pondering bug 88362 I noticed that calling __builtin_has_attribute (r, aligned (N)) on a reference like in the test case below causes an ICE: $ cat t.C && gcc -O2 -S -Wall -Wextra t.C extern __attribute__ ((aligned (8))) int &r; int f () { return __builtin_has_attribute (r, aligned (8)); } t.C: In function ‘int f()’: t.C:5:48: internal compiler error: tree check: expected tree that contains ‘decl minimal’ structure, have ‘indirect_ref’ in build_decl, at tree.c:4988 5 | return __builtin_has_attribute (r, aligned (8)); | ^ 0x1891993 tree_contains_struct_check_failed(tree_node const*, tree_node_structure_enum, char const*, int, char const*) /ssd/src/gcc/svn/gcc/tree.c:9931 0x82a67e contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*) /ssd/src/gcc/svn/gcc/tree.h:3268 0x187db4d build_decl(unsigned int, tree_code, tree_node*, tree_node*) /ssd/src/gcc/svn/gcc/tree.c:4988 0xc6513e validate_attribute /ssd/src/gcc/svn/gcc/c-family/c-attribs.c:3998 0xc65291 has_attribute(unsigned int, tree_node*, tree_node*, tree_node* (*)(tree_node*)) /ssd/src/gcc/svn/gcc/c-family/c-attribs.c:4031 0xa121bf cp_parser_has_attribute_expression /ssd/src/gcc/svn/gcc/cp/parser.c:8519 0xa112a2 cp_parser_unary_expression /ssd/src/gcc/svn/gcc/cp/parser.c:8132 0xa133d7 cp_parser_cast_expression /ssd/src/gcc/svn/gcc/cp/parser.c:9281 0xa134bb cp_parser_binary_expression /ssd/src/gcc/svn/gcc/cp/parser.c:9382 0xa1438c cp_parser_assignment_expression /ssd/src/gcc/svn/gcc/cp/parser.c:9677 0xa1473c cp_parser_expression /ssd/src/gcc/svn/gcc/cp/parser.c:9846 0xa1b527 cp_parser_jump_statement /ssd/src/gcc/svn/gcc/cp/parser.c:12778 0xa174e2 cp_parser_statement /ssd/src/gcc/svn/gcc/cp/parser.c:11060 0xa18499 cp_parser_statement_seq_opt /ssd/src/gcc/svn/gcc/cp/parser.c:11526 0xa1838d cp_parser_compound_statement /ssd/src/gcc/svn/gcc/cp/parser.c:11480 0xa2da81 cp_parser_function_body /ssd/src/gcc/svn/gcc/cp/parser.c:22361 0xa2dc72 cp_parser_ctor_initializer_opt_and_function_body /ssd/src/gcc/svn/gcc/cp/parser.c:22396 0xa37e4a cp_parser_function_definition_after_declarator /ssd/src/gcc/svn/gcc/cp/parser.c:27449 0xa37c75 cp_parser_function_definition_from_specifiers_and_declarator /ssd/src/gcc/svn/gcc/cp/parser.c:27366 0xa29339 cp_parser_init_declarator /ssd/src/gcc/svn/gcc/cp/parser.c:20051 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.