The C++ file: struct bar { static int foo; }; int a = __builtin_offsetof(bar, foo); The error: > g++ -c foo.cc foo.cc:5: internal compiler error: in fold_offsetof_1, at c-common.c:5998 GCC snapshot version: g++ (GCC) 4.1.1 20060512 (prerelease)
Confirmed.
Testing a patch.
Subject: Bug number PR c++/27601 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00161.html
Subject: Bug 27601 Author: reichelt Date: Sun Jun 4 23:42:04 2006 New Revision: 114369 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114369 Log: PR c++/27601 * c-common.c (fold_offsetof_1): Handle static members. * g++.dg/ext/offsetof1.C: New test. Added: trunk/gcc/testsuite/g++.dg/ext/offsetof1.C Modified: trunk/gcc/ChangeLog trunk/gcc/c-common.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 27601 Author: reichelt Date: Sun Jun 4 23:47:15 2006 New Revision: 114370 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114370 Log: PR c++/27601 * c-common.c (fold_offsetof_1): Handle static members. * g++.dg/ext/offsetof1.C: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/g++.dg/ext/offsetof1.C Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/c-common.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Subject: Bug 27601 Author: reichelt Date: Sun Jun 4 23:51:52 2006 New Revision: 114371 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114371 Log: PR c++/27601 * c-common.c (fold_offsetof_1): Handle static members. * g++.dg/ext/offsetof1.C: New test. Added: branches/gcc-4_0-branch/gcc/testsuite/g++.dg/ext/offsetof1.C Modified: branches/gcc-4_0-branch/gcc/ChangeLog branches/gcc-4_0-branch/gcc/c-common.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
Original testcase on mainline, 4.1 branch, and 4.0 branch. However, we still ICE on member functions (static or non-static): ======================================== struct bar { int foo(); }; int a = __builtin_offsetof(bar, foo); ======================================== bug.cc:5: internal compiler error: tree check: expected field_decl, have baselink in fold_offsetof_1, at c-common.c:5997 Please submit a full bug report, [etc.] Will post a patch for this problem, too.
Subject: Bug number PR c++/27601 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00206.html
Subject: Bug number PR c++/27601 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00347.html
Subject: Bug 27601 Author: reichelt Date: Wed Jun 7 16:08:30 2006 New Revision: 114469 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114469 Log: PR c++/27601 * cp-tree.h (finish_offsetof): Add prototype. * semantics.c (finish_offsetof): New function. * parser.c (cp_parser_builtin_offsetof): Call it instead of fold_offsetof. * pt.c (tsubst_copy_and_build): Likewise. * g++.dg/ext/offsetof1.C: Test member functions. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/parser.c trunk/gcc/cp/pt.c trunk/gcc/cp/semantics.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/ext/offsetof1.C
Subject: Bug 27601 Author: reichelt Date: Wed Jun 7 16:12:55 2006 New Revision: 114470 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114470 Log: PR c++/27601 * cp-tree.h (finish_offsetof): Add prototype. * semantics.c (finish_offsetof): New function. * parser.c (cp_parser_builtin_offsetof): Call it instead of fold_offsetof. * pt.c (tsubst_copy_and_build): Likewise. * g++.dg/ext/offsetof1.C: Test member functions. Modified: branches/gcc-4_1-branch/gcc/cp/ChangeLog branches/gcc-4_1-branch/gcc/cp/cp-tree.h branches/gcc-4_1-branch/gcc/cp/parser.c branches/gcc-4_1-branch/gcc/cp/pt.c branches/gcc-4_1-branch/gcc/cp/semantics.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog branches/gcc-4_1-branch/gcc/testsuite/g++.dg/ext/offsetof1.C
Subject: Bug 27601 Author: reichelt Date: Wed Jun 7 16:18:06 2006 New Revision: 114471 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114471 Log: PR c++/27601 * cp-tree.h (finish_offsetof): Add prototype. * semantics.c (finish_offsetof): New function. * parser.c (cp_parser_builtin_offsetof): Call it instead of fold_offsetof. * pt.c (tsubst_copy_and_build): Likewise. * g++.dg/ext/offsetof1.C: Test member functions. Modified: branches/gcc-4_0-branch/gcc/cp/ChangeLog branches/gcc-4_0-branch/gcc/cp/cp-tree.h branches/gcc-4_0-branch/gcc/cp/parser.c branches/gcc-4_0-branch/gcc/cp/pt.c branches/gcc-4_0-branch/gcc/cp/semantics.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog branches/gcc-4_0-branch/gcc/testsuite/g++.dg/ext/offsetof1.C
Fixed on mainline, 4.1 branch, and 4.0 branch.
Subject: Bug 27601 Author: reichelt Date: Mon Jun 12 22:56:07 2006 New Revision: 114588 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114588 Log: PR c++/27601 * semantics.c (finish_offsetof): Handle pseudo-destructors. * g++.dg/ext/offsetof1.C: Add test for pseudo-destructors. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/semantics.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/ext/offsetof1.C
Subject: Bug 27601 Author: reichelt Date: Mon Jun 12 23:00:00 2006 New Revision: 114589 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114589 Log: PR c++/27601 * semantics.c (finish_offsetof): Handle pseudo-destructors. * g++.dg/ext/offsetof1.C: Add test for pseudo-destructors. Modified: branches/gcc-4_1-branch/gcc/cp/ChangeLog branches/gcc-4_1-branch/gcc/cp/semantics.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog branches/gcc-4_1-branch/gcc/testsuite/g++.dg/ext/offsetof1.C
Subject: Bug 27601 Author: reichelt Date: Mon Jun 12 23:03:36 2006 New Revision: 114590 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114590 Log: PR c++/27601 * semantics.c (finish_offsetof): Handle pseudo-destructors. * g++.dg/ext/offsetof1.C: Add test for pseudo-destructors. Modified: branches/gcc-4_0-branch/gcc/cp/ChangeLog branches/gcc-4_0-branch/gcc/cp/semantics.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog branches/gcc-4_0-branch/gcc/testsuite/g++.dg/ext/offsetof1.C
Now the ICE with pseudo-destructors described in http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00677.html is also fixed.
Subject: Bug number PR c++/27601 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00677.html
*** Bug 29745 has been marked as a duplicate of this bug. ***