From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 828753857C4D; Sat, 17 Oct 2020 07:50:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 828753857C4D From: "tangyixuan at mail dot dlut.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/97468] New: gcc crashes when using __may_alias__ attribute Date: Sat, 17 Oct 2020 07:50:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tangyixuan at mail dot dlut.edu.cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2020 07:50:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97468 Bug ID: 97468 Summary: gcc crashes when using __may_alias__ attribute Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tangyixuan at mail dot dlut.edu.cn Target Milestone: --- Hi, the following code uses '__attribute__ ((__may_alias__))' to alias a st= ruct 'S' to 'a'. However, gcc crashes at compilation time while clang successful= ly compiles. gcc doc: https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Common-Type-Attributes.html#C= ommon-Type-Attributes 'Accesses through pointers to types with this attribute are not subject to type-based alias analysis, but are instead assumed to be able to alias any other type of objects.' $ cat s.cpp template struct S{}; auto __attribute__ ((__may_alias__)) a=3DS{}; $ g++ -c s.cpp s.cpp:2:38: internal compiler error: in layout_type, at stor-layout.c:2618 2 | auto __attribute__ ((__may_alias__)) a=3DS{}; | ^ 0x62d384 layout_type(tree_node*) ../../gcc-11-20201011/gcc/stor-layout.c:2618 0xebaf34 type_hash_canon(unsigned int, tree_node*) ../../gcc-11-20201011/gcc/tree.c:7140 0x7e6beb build_type_attribute_qual_variant(tree_node*, tree_node*, int) ../../gcc-11-20201011/gcc/attribs.c:1166 0x7e8702 build_type_attribute_variant(tree_node*, tree_node*) ../../gcc-11-20201011/gcc/attribs.c:1377 0x7e8702 decl_attributes(tree_node**, tree_node*, int, tree_node*) ../../gcc-11-20201011/gcc/attribs.c:794 0x6d9e93 cplus_decl_attributes(tree_node**, tree_node*, int) ../../gcc-11-20201011/gcc/cp/decl2.c:1595 0x6cd1bf start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) ../../gcc-11-20201011/gcc/cp/decl.c:5267 0x7590ce cp_parser_init_declarator ../../gcc-11-20201011/gcc/cp/parser.c:20936 0x73a65c cp_parser_simple_declaration ../../gcc-11-20201011/gcc/cp/parser.c:13878 0x7630a6 cp_parser_declaration ../../gcc-11-20201011/gcc/cp/parser.c:13577 0x7636dd cp_parser_translation_unit ../../gcc-11-20201011/gcc/cp/parser.c:4793 0x7636dd c_parse_file() ../../gcc-11-20201011/gcc/cp/parser.c:44172 0x82f13d c_common_parse_file() ../../gcc-11-20201011/gcc/c-family/c-opts.c:1188 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions.=