Bug 28595 - [4.1 regression] ICE with invalid const static variable
Summary: [4.1 regression] ICE with invalid const static variable
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P2 normal
Target Milestone: 4.1.2
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-08-04 00:55 UTC by Volker Reichelt
Modified: 2006-08-26 17:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-08-14 19:02:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-08-04 00:55:18 UTC
The following invalid code snippet triggers an ICE since GCC 4.1.0:

===============================
template<int> struct A
{
  static const int i;
};

template<int N> struct B
{
  char c[A<N>::i], d;
};

B<0> b;
===============================

bug.cc: In instantiation of 'B<0>':
bug.cc:11:   instantiated from here
bug.cc:7: internal compiler error: tree check: expected integer_cst, have nop_expr in walk_subobject_offsets, at cp/class.c:3126
Please submit a full bug report, [etc.]
Comment 1 Janis Johnson 2006-08-11 22:24:37 UTC
A regression hunt on powerpc-linux identified the following patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=106566

    r106566 | mmitchel | 2005-11-06 19:41:18 +0000 (Sun, 06 Nov 2005)
Comment 2 Volker Reichelt 2006-08-14 19:02:39 UTC
Confirmed by Janis.
Comment 3 Mark Mitchell 2006-08-26 16:23:43 UTC
Subject: Bug 28595

Author: mmitchel
Date: Sat Aug 26 16:23:33 2006
New Revision: 116468

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116468
Log:
	PR c++/28588
	* class.c (resolve_address_of_overloaded_function): Add
	access_path parameter.  Perform access checks.
	(instantiate_type): Adjust call to
	resolve_address_of_overloaded_function.  Remove unnecessary code.
	* tree.c (is_overloaded_fn): Document.  Return 2 when there are
	acutally multiple functions.
	(really_overloaded_fn): Use is_overloaded_fn.
	* mangle.c (write_expression): Handle BASELINKs.
	* cp-tree.h (really_overloaded_fn): Return bool.
	(baselink_for_fns): Declare.
	* search.c (lookup_member): Check access for single static
	functions here.
	* pt.c (convert_nontype_argument_function): Handle BASELINKs.
	(tsubst_copy_and_build): Generate BASELINKs for template-ids.
	* semantics.c (finish_call_expr): Use baselink_for_fns.
	(baselink_for_fns): New function.
	(finish_id_expression): Use it.
	* parser.c (cp_parser_template_argument): Don't strip BASELINKs.
	PR c++/28595
	* pt.c (tsubst): Issue errors about attempts to create VLAs at
	template-instantiation time.
	PR c++/28588
	* g++.dg/inherit/access6.C: New test.
	* g++.dg/inherit/access7.C: Likewise.
	PR c++/28595
	* g++.dg/template/array15.C: New test.
	* g++.dg/template/crash2.C: Tweak error markers.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/access6.C
    trunk/gcc/testsuite/g++.dg/inherit/access7.C
    trunk/gcc/testsuite/g++.dg/template/array15.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/mangle.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/search.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/tree.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/crash2.C

Comment 4 Mark Mitchell 2006-08-26 16:38:25 UTC
Fixed in 4.2.0.
Comment 5 Mark Mitchell 2006-08-26 17:14:13 UTC
Subject: Bug 28595

Author: mmitchel
Date: Sat Aug 26 17:13:52 2006
New Revision: 116471

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116471
Log:
	PR c++/28595
	* pt.c (tsubst): Issue errors about attempts to create VLAs at
	template-instantiation time.
	PR c++/28595
	* g++.dg/template/array15.C: New test.
	* g++.dg/template/crash2.C: Tweak error markers.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/array15.C
Modified:
    branches/gcc-4_1-branch/gcc/cp/ChangeLog
    branches/gcc-4_1-branch/gcc/cp/pt.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/crash2.C

Comment 6 Mark Mitchell 2006-08-26 17:14:40 UTC
Fixed in 4.1.2.
Comment 7 Mark Mitchell 2006-08-26 17:16:53 UTC
Fixed in 4.1.2.