Bug 27601 - [4.0/4.1/4.2 Regression] ICE (in fold_offsetof_1, at c-common.c:5998) on strange offsetof
Summary: [4.0/4.1/4.2 Regression] ICE (in fold_offsetof_1, at c-common.c:5998) on stra...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.1
: P2 minor
Target Milestone: 4.0.4
Assignee: Volker Reichelt
URL:
Keywords: ice-on-invalid-code, monitored
: 29745 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-14 11:44 UTC by Patrik Hägglund
Modified: 2006-11-06 23:08 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.6
Known to fail: 4.2.0 4.1.0 4.0.3
Last reconfirmed: 2006-05-15 20:52:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrik Hägglund 2006-05-14 11:44:43 UTC
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)
Comment 1 Richard Biener 2006-05-15 20:52:42 UTC
Confirmed.
Comment 2 Volker Reichelt 2006-06-02 23:24:41 UTC
Testing a patch.
Comment 3 patchapp@dberlin.org 2006-06-03 19:30:17 UTC
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
Comment 4 Volker Reichelt 2006-06-04 23:42:45 UTC
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

Comment 5 Volker Reichelt 2006-06-04 23:47:22 UTC
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

Comment 6 Volker Reichelt 2006-06-04 23:51:59 UTC
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

Comment 7 Volker Reichelt 2006-06-05 00:03:06 UTC
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.
Comment 8 patchapp@dberlin.org 2006-06-05 11:55:28 UTC
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
Comment 9 patchapp@dberlin.org 2006-06-07 07:46:03 UTC
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
Comment 10 Volker Reichelt 2006-06-07 16:08:49 UTC
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

Comment 11 Volker Reichelt 2006-06-07 16:15:50 UTC
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

Comment 12 Volker Reichelt 2006-06-07 16:18:57 UTC
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

Comment 13 Volker Reichelt 2006-06-07 16:20:42 UTC
Fixed on mainline, 4.1 branch, and 4.0 branch.
Comment 14 Volker Reichelt 2006-06-12 22:56:14 UTC
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

Comment 15 Volker Reichelt 2006-06-12 23:00:13 UTC
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

Comment 16 Volker Reichelt 2006-06-12 23:03:44 UTC
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

Comment 17 Volker Reichelt 2006-06-12 23:07:19 UTC
Now the ICE with pseudo-destructors described in
http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00677.html
is also fixed.
Comment 18 patchapp@dberlin.org 2006-06-13 00:10:19 UTC
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
Comment 19 Andrew Pinski 2006-11-06 23:08:39 UTC
*** Bug 29745 has been marked as a duplicate of this bug. ***