The following invalid code snippet triggers an ICE since GCC 4.0.0: ========================================= struct A { A operator[] (int); }; struct B { A a; }; void foo() { __builtin_offsetof(B, a[0]); } ========================================= bug.cc: In function 'void foo()': bug.cc:13: internal compiler error: in fold_offsetof_1, at c-common.c:6850 Please submit a full bug report, [etc.] Before, the code was rejected as __builtin_offsetof was not yet supported. The problem is related to PR28573.
Closing 4.1 branch.
Paolo, can you have a quick look to this one? Seems indeed in the same ball park of PR28573, which you fixed. Is it just matter of handling TARGET_EXPR the same way of CALL_EXPR in fold_offsetof_1? (passes testing for me...)
Indeed, it's just that this operator[] throws.
Ok, thanks, I'll submit a patchlet.
Fixed for 4.4.0.
Subject: Bug 35321 Author: paolo Date: Wed Aug 27 17:08:40 2008 New Revision: 139628 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139628 Log: 2008-08-27 Paolo Carlini <paolo.carlini@oracle.com> PR c++/35321 * c-common.c (fold_offsetof_1): Handle TARGET_EXPR like CALL_EXPR. /testsuite 2008-08-27 Paolo Carlini <paolo.carlini@oracle.com> PR c++/35321 * g++.dg/parse/offsetof8.C: New. Added: trunk/gcc/testsuite/g++.dg/parse/offsetof8.C Modified: trunk/gcc/ChangeLog trunk/gcc/c-common.c trunk/gcc/testsuite/ChangeLog
I have a real fix for this bug, and we get an error message now. t.cc:13: error: using [] in offset with a pointer.
Closing 4.2 branch.
WONTFIX for 4.3.