public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97468] New: gcc crashes when using __may_alias__ attribute
@ 2020-10-17 7:50 tangyixuan at mail dot dlut.edu.cn
2020-10-19 7:22 ` [Bug c++/97468] " marxin at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: tangyixuan at mail dot dlut.edu.cn @ 2020-10-17 7:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97468
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 struct
'S' to 'a'. However, gcc crashes at compilation time while clang successfully
compiles.
gcc doc:
https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Common-Type-Attributes.html#Common-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<typename T> struct S{};
auto __attribute__ ((__may_alias__)) a=S<int>{};
$ 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=S<int>{};
| ^
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 <https://gcc.gnu.org/bugs/> for instructions.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97468] gcc crashes when using __may_alias__ attribute
2020-10-17 7:50 [Bug c++/97468] New: gcc crashes when using __may_alias__ attribute tangyixuan at mail dot dlut.edu.cn
@ 2020-10-19 7:22 ` marxin at gcc dot gnu.org
2020-10-19 7:28 ` rguenth at gcc dot gnu.org
2021-10-01 9:57 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-10-19 7:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97468
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-10-19
Ever confirmed|0 |1
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, it's at least as old as 4.8.0.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97468] gcc crashes when using __may_alias__ attribute
2020-10-17 7:50 [Bug c++/97468] New: gcc crashes when using __may_alias__ attribute tangyixuan at mail dot dlut.edu.cn
2020-10-19 7:22 ` [Bug c++/97468] " marxin at gcc dot gnu.org
@ 2020-10-19 7:28 ` rguenth at gcc dot gnu.org
2021-10-01 9:57 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-19 7:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97468
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
#1 0x00000000016e9d82 in layout_type (
type=<template_type_parm 0x7ffff696adc8 auto>)
at /home/rguenther/src/gcc2/gcc/stor-layout.c:2618
but of course calling layout_type from type_hash_canon is quite fishy as
we'll end up layouting a template_type_parm here ... now, feeding this
to type_hash_canon is fishy as well so the FE should probably not call
any of the attribute handlers on those ...
tree
type_hash_canon (unsigned int hashcode, tree type)
{
type_hash in;
type_hash **loc;
/* The hash table only contains main variants, so ensure that's what we're
being passed. */
gcc_assert (TYPE_MAIN_VARIANT (type) == type);
/* The TYPE_ALIGN field of a type is set by layout_type(), so we
must call that routine before comparing TYPE_ALIGNs. */
layout_type (type);
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97468] gcc crashes when using __may_alias__ attribute
2020-10-17 7:50 [Bug c++/97468] New: gcc crashes when using __may_alias__ attribute tangyixuan at mail dot dlut.edu.cn
2020-10-19 7:22 ` [Bug c++/97468] " marxin at gcc dot gnu.org
2020-10-19 7:28 ` rguenth at gcc dot gnu.org
@ 2021-10-01 9:57 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-01 9:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97468
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 89867.
*** This bug has been marked as a duplicate of bug 89867 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-01 9:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-17 7:50 [Bug c++/97468] New: gcc crashes when using __may_alias__ attribute tangyixuan at mail dot dlut.edu.cn
2020-10-19 7:22 ` [Bug c++/97468] " marxin at gcc dot gnu.org
2020-10-19 7:28 ` rguenth at gcc dot gnu.org
2021-10-01 9:57 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).