A G++ from today's trunk (20110826) segv's on a reduced test case (using delta) like so: bergner@igoo:~> cat minimal.ii typedef long unsigned int size_t; namespace std __attribute__ ((__visibility__ ("default"))) { using::size_t; } typedef unsigned char uint8_t; namespace std { namespace decimal { template < class _Fmt > struct _FmtTraits; class decimal32; } } namespace std { namespace decimal { template <> class _FmtTraits < decimal32 > { public: static const std::size_t _NumBytes = 4UL; }; template < class _Tr > class _DecBase { uint8_t _Bytes[_Tr::_NumBytes]; }; class decimal32:public _DecBase < _FmtTraits < decimal32 > > { decimal32 () { } }; } } bergner@igoo:~> /home/bergner/gcc/install/gcc-mainline-debug/bin/g++ -Wall -S minimal.ii g++: internal compiler error: Segmentation fault (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. GDB show this backtrace: #0 0x0000000010412cc8 in decl_is_template_id (decl=0xfffb6edcc18, template_info=0xfffb6edcc18) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:267 #1 0x000000001041b44c in write_nested_name (decl=0xfffb6e24ac0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:928 #2 0x000000001041ab48 in write_name (decl=0xfffb6e24ac0, ignore_local_scope=0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:855 #3 0x00000000104284e4 in write_class_enum_type (type=0xfffb6edd4a0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2398 #4 0x0000000010424840 in write_type (type=0xfffb6edd4a0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:1884 #5 0x000000001042d1ec in write_template_arg (node=0xfffb6edcc18) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2843 #6 0x0000000010428868 in write_template_args (args=0xfffb6f13a70) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2427 #7 0x000000001041b50c in write_nested_name (decl=0xfffb6e245b8) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:932 #8 0x000000001041ab48 in write_name (decl=0xfffb6e245b8, ignore_local_scope=0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:855 #9 0x00000000104284e4 in write_class_enum_type (type=0xfffb6edccc0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2398 #10 0x0000000010424840 in write_type (type=0xfffb6edccc0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:1884 #11 0x000000001042d1ec in write_template_arg (node=0xfffb6edccc0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2843 #12 0x0000000010428868 in write_template_args (args=0xfffb6f14088) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2427 #13 0x000000001041b50c in write_nested_name (decl=0xfffb6e24ac0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:932 #14 0x000000001041ab48 in write_name (decl=0xfffb6e24ac0, ignore_local_scope=0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:855 #15 0x00000000104284e4 in write_class_enum_type (type=0xfffb6edd4a0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2398 #16 0x0000000010424840 in write_type (type=0xfffb6edd4a0) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:1884 #17 0x000000001042d1ec in write_template_arg (node=0xfffb6edcc18) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2843 #18 0x0000000010428868 in write_template_args (args=0xfffb6f13a70) at /home/bergner/gcc/gcc-mainline-base/gcc/cp/mangle.c:2427 ... The backtrace also show we have 10's of thousands of frames stacked repeated over and over, so it looks like we've gone into some type of infinite recursion. A quick look at GCC 4.6 show's it fails in the same manner. I haven't checked anything earlier.
Related to Bug 46862.
Caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177647
Oops, sorry, that was for PR50208.
I'd say this is invalid, TYPE_TRANSPARENT_AGGR is an ugly hack and we should perhaps limit it just to scalar fields.
Created attachment 25125 [details] gcc47-pr50207.patch Untested patch which adds that limitation. <decimal/decimal> still seems to work.
The problem here is not that the first field is aggregate, but that the first field is a fake field for the base class. I'll adjust the patch accordingly.
Author: jason Date: Tue Aug 30 04:30:42 2011 New Revision: 178276 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178276 Log: PR c++/50207 * class.c (finish_struct_1): Complain if the first field is artificial. Added: trunk/gcc/testsuite/g++.dg/dfp/base.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/class.c trunk/gcc/testsuite/ChangeLog
Fixed.
Author: jason Date: Tue Aug 30 21:48:34 2011 New Revision: 178343 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178343 Log: PR c++/50207 * class.c (finish_struct_1): Complain if the first field is artificial. Added: branches/gcc-4_6-branch/gcc/testsuite/g++.dg/dfp/base.C Modified: branches/gcc-4_6-branch/gcc/cp/ChangeLog branches/gcc-4_6-branch/gcc/cp/class.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Author: bergner Date: Thu Sep 8 18:08:53 2011 New Revision: 178703 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178703 Log: gcc/ Backport from mainline 2011-08-23 Jakub Jelinek <jakub@redhat.com> PR c++/46862 * class.c (finish_struct_1): If TYPE_TRANSPARENT_AGGR is set on a type which doesn't have any fields, clear it and diagnose. 2011-08-29 Jakub Jelinek <jakub@redhat.com> Jason Merrill <jason@redhat.com> PR c++/50207 * class.c (finish_struct_1): Complain if the first field is artificial. gcc/testsuite/ Backport from mainline 2011-08-23 Jakub Jelinek <jakub@redhat.com> PR c++/46862 * g++.dg/dfp/nofields.C: New test. 2011-08-29 Jakub Jelinek <jakub@redhat.com> Jason Merrill <jason@redhat.com> PR c++/50207 * g++.dg/dfp/base.C: New test. Added: branches/ibm/gcc-4_5-branch/gcc/testsuite/g++.dg/dfp/base.C branches/ibm/gcc-4_5-branch/gcc/testsuite/g++.dg/dfp/nofields.C Modified: branches/ibm/gcc-4_5-branch/gcc/ChangeLog.ibm branches/ibm/gcc-4_5-branch/gcc/cp/class.c branches/ibm/gcc-4_5-branch/gcc/testsuite/ChangeLog.ibm