Bug 35321 - [4.3 regression] ICE with invalid use of __builtin_offsetof
Summary: [4.3 regression] ICE with invalid use of __builtin_offsetof
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code, monitored
Depends on: 28573
Blocks:
  Show dependency treegraph
 
Reported: 2008-02-23 18:30 UTC by Volker Reichelt
Modified: 2009-04-22 15:31 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.0
Known to fail: 4.3.3
Last reconfirmed: 2008-08-17 00:11:23


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2008-02-23 18:30:28 UTC
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.
Comment 1 Joseph S. Myers 2008-07-04 22:34:42 UTC
Closing 4.1 branch.
Comment 2 Paolo Carlini 2008-08-17 15:40:40 UTC
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...)
Comment 3 Paolo Bonzini 2008-08-17 16:05:27 UTC
Indeed, it's just that this operator[] throws.
Comment 4 Paolo Carlini 2008-08-17 16:17:19 UTC
Ok, thanks, I'll submit a patchlet.
Comment 5 Paolo Carlini 2008-08-27 17:09:44 UTC
Fixed for 4.4.0.
Comment 6 paolo@gcc.gnu.org 2008-08-27 17:10:09 UTC
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

Comment 7 Andrew Pinski 2009-01-02 22:37:41 UTC
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.

Comment 8 Joseph S. Myers 2009-03-31 20:21:13 UTC
Closing 4.2 branch.
Comment 9 Richard Biener 2009-04-22 15:31:15 UTC
WONTFIX for 4.3.