$ cat ice.c typedef struct S { unsigned long flags; }S_t; struct dp { S_t c; }; typedef S_t __attribute__((__may_alias__)) cmonkey; static void handler(void *vp) { struct dp *dp; cmonkey *cm = vp; dp->c = *cm; } $ gcc -m32 -std=gnu99 -W -Wall -g3 -c ice.c ice.c:7: internal compiler error: in modified_type_die, at dwarf2out.c:8463 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/ccakn2Ps.out file, please attach this to your bugreport. $
Other ways to ICE gcc: /////////////////////// typedef struct S { unsigned long flags; }S_t; typedef S_t __attribute__((__may_alias__)) cmonkey; S_t *handler(void *vp) { cmonkey *cm = vp; return cm; } //////////////////////// typedef struct S { unsigned long flags; }S_t; typedef S_t __attribute__((__may_alias__)) cmonkey; S_t handler(void *vp) { cmonkey *cm = vp; return *cm; } ////////////////////// typedef struct S { unsigned long flags; }S_t; typedef S_t __attribute__((__may_alias__)) cmonkey; int handler(void *vp) { S_t dp; cmonkey *cm = vp; dp = *cm; } /////////////////// typedef struct S { unsigned long flags; }S_t; typedef S_t __attribute__((__may_alias__)) cmonkey; int handler(void *vp) { S_t * dp; cmonkey *cm = vp; *dp = *cm; } //////////////////////// Besides a fix, I could use some workaround suggestions. This itself is an attempted workaround for a suspected bug involving memcpy, so that won't do.
Hey, I don't even need to use the types. The typedef alone is enough to ICE gcc: typedef struct S { unsigned long flags; }S_t; typedef S_t __attribute__((__may_alias__)) cmonkey; int main(int argc, char *argv[]){ }
Confirmed, this is an user visable regression in that the code did not ICE in 3.2.3 even though the attribute is ignored.
I cannot reproduce this any longer with 4.2: trunk-g/gcc> ./cc1 -quiet t.i -g3 -std=gnu99 -W -Wall -m32 t.i: In function 'handler': t.i:12: error: incompatible types in assignment though cc1plus ICEs (differently) now: trunk-g/gcc> ./cc1plus -quiet t.i -g3 -std=gnu99 -W -Wall -m32 cc1plus: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ t.i: In function 'void handler(void*)': t.i:11: error: invalid conversion from 'void*' to 'cmonkey*' t.i:12: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. Starting program: /abuild/rguenther/trunk-g/gcc/cc1plus -quiet t.i -g3 -std=gnu99 -W -Wall -m32 cc1plus: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ t.i: In function 'void handler(void*)': t.i:11: error: invalid conversion from 'void*' to 'cmonkey*' Program received signal SIGSEGV, Segmentation fault. 0x00000000005aa1b8 in decl_namespace_context (decl=0x2b8e53df20b0) at /space/rguenther/src/svn/trunk/gcc/cp/tree.c:1391 1391 decl = CP_DECL_CONTEXT (TYPE_MAIN_DECL (decl)); (gdb) print decl->type.main_variant->common.chain $1 = (tree) 0x0
We're getting a type variant with the attribute created which shares TYPE_NAME which in turn points back to the wrong (un-attributed) type. So we do not create a die for the attributed type. This can be worked around with Index: tree.c =================================================================== *** tree.c (revision 117822) --- tree.c (working copy) *************** build_type_attribute_variant (tree ttype *** 3310,3315 **** --- 3310,3320 ---- ntype = type_hash_canon (hashcode, ntype); ttype = build_qualified_type (ntype, TYPE_QUALS (ttype)); + if (TYPE_NAME (ttype)) + { + TYPE_NAME (ttype) = copy_node (TYPE_NAME (ttype)); + TREE_TYPE (TYPE_NAME (ttype)) = ttype; + } } return ttype; after which we have the same situation as currently on mainline (cc1plus segfaults, cc1 is fine). I guess something fixed this on the mainline - any idea what?
Janis, can you hunt this on the mainline? I want to know at what point we changed from the ICE in dwarf2out to issuing an error (for cc1). Thanks!
(In reply to comment #6) > Janis, can you hunt this on the mainline? I want to know at what point we > changed > from the ICE in dwarf2out to issuing an error (for cc1). We still ICE for the testcase in comment #2.
In case comment #4 was meant to imply that a non-ICE error is fine: Please note that the crashing code is very nearly the __may_alias__ example given in the gcc documentation. The main difference is that I used a struct. This really needs to work for things like malloc arena headers, so the "t.i:12: error: incompatible types in assignment" and "t.i:11: error: invalid conversion from 'void*' to 'cmonkey*'" stuff is no good.
I did it again, but this time in splice_child_die. $ gcc -g3 -Os -W -Wall -std=gnu99 jji.c jji.c:3: warning: useless storage class specifier in empty declaration jji.c:5: internal compiler error: in splice_child_die, at dwarf2out.c:5492 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/ccg46xph.out file, please attach this to yo ur bugreport. $ cat jji.c typedef struct S { unsigned long flags; }; typedef struct S __attribute__((__may_alias__)) cmonkey; int main(int argc,char *argv[]){ return 0; } $
An enum will crash it too. This one is in modified_type_die like the original. $ gcc -g3 -Os -W -Wall -std=gnu99 kku.c kku.c:3: internal compiler error: in modified_type_die, at dwarf2out.c:8463 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/ccksgAgj.out file, please attach this to your bugreport. $ cat kku.c typedef enum E {foo, bar} E; typedef E __attribute__((__may_alias__)) cmonkey; int main(int argc,char *argv[]){ return 0; } $
A regression hunt on powerpc-linux using the testcase from the submitter's description showed that it went from an ICE to an error with this patch: http://gcc.gnu.org/viewcvs?view=rev&rev=110925 r110925 | geoffk | 2006-02-13 21:17:59 +0000 (Mon, 13 Feb 2006) Let me know if other reghunts would be useful here.
Isn't this a dup of bug 28834?
(In reply to comment #12) > Isn't this a dup of bug 28834? Related for sure, dup unknown at this point.
*** Bug 30628 has been marked as a duplicate of this bug. ***
won't fix in GCC-4.0.x. Adjusting milestone.
*** Bug 32326 has been marked as a duplicate of this bug. ***
is a dup of 28834. *** This bug has been marked as a duplicate of 28834 ***
Subject: Bug 29436 Author: jason Date: Mon Nov 19 21:35:13 2007 New Revision: 130297 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130297 Log: PR debug/29436, c/32326 * tree.c (build_type_attribute_qual_variant): Refuse to make a distinct copy of a struct/enum type. Use build_distinct_type_copy. * doc/extend.texi (Type Attributes): Don't encourage people to add attributes to struct/enum types in a typedef. Fix transparent_union example. * tree-inline.c (remap_type_1): Remove code that's redundant with remap_type. (build_duplicate_type): Set id.copy_decl. * c-common.c (handle_transparent_union_attribute): Simplify logic. Modified: trunk/gcc/ChangeLog trunk/gcc/c-common.c trunk/gcc/doc/extend.texi trunk/gcc/testsuite/gcc.c-torture/execute/mayalias-2.c trunk/gcc/testsuite/gcc.c-torture/execute/mayalias-3.c trunk/gcc/tree-inline.c trunk/gcc/tree.c