Bug 29727 - [4.3 regression] ICE on invalid initializer for template member
Summary: [4.3 regression] ICE on invalid initializer for template member
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P4 minor
Target Milestone: 4.4.0
Assignee: Simon Martin
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored, rejects-valid
Depends on:
Blocks:
 
Reported: 2006-11-05 20:22 UTC by Volker Reichelt
Modified: 2009-04-22 15:23 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-10-05 07:27:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-11-05 20:22:34 UTC
The following invalid code snippet triggers an ICE since GCC 3.3:

=================================================
template<int> struct A
{
  static int a[1];
};

template<int N> int A<N>::a[1] = { X: 0 };

void foo()
{
  A<0>::a;
}
=================================================

bug.cc: In instantiation of 'int A<0>::a [1]':
bug.cc:10:   instantiated from here
bug.cc:6: error: 'X' was not declared in this scope
bug.cc:6: internal compiler error: in reshape_init_array_1, at cp/decl.c:4350
Please submit a full bug report, [etc.]
Comment 1 Andrew Pinski 2006-11-26 00:19:12 UTC
Confirmed.
Comment 2 Gabriel Dos Reis 2007-02-03 20:49:10 UTC
won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 3 Volker Reichelt 2007-07-23 21:31:53 UTC
The bug disappeared on the 4.1 branch (already in GCC 4.1.2).
It is still present on the 4.2 branch and mainline.
Comment 4 Paolo Carlini 2007-09-25 14:54:05 UTC
When fixing this bug we also want to make sure we do not reject this valid variant:

template<int> struct A
{
  struct S { int X; };
  static S a;
};

template<int N> typename A<N>::S A<N>::a = { X : 1 };

void foo()
{
  A<0>::a;
}
Comment 5 Mark Mitchell 2007-10-09 19:22:05 UTC
Change target milestone to 4.2.3, as 4.2.2 has been released.
Comment 6 Joseph S. Myers 2008-02-01 16:53:36 UTC
4.2.3 is being released now, changing milestones of open bugs to 4.2.4.
Comment 7 Joseph S. Myers 2008-05-19 20:22:59 UTC
4.2.4 is being released, changing milestones to 4.2.5.
Comment 8 Simon Martin 2008-10-05 07:27:47 UTC
PR37736 opened for the reject valid case (it's a different bug).

Patch for the ICE submitted here:
  http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00134.html
Comment 9 andreasmeier80 2009-03-27 07:18:31 UTC
Approved: http://gcc.gnu.org/ml/gcc-patches/2009-03/msg01080.html
Comment 10 hjl@gcc.gnu.org 2009-03-27 13:11:57 UTC
Subject: Bug 29727

Author: hjl
Date: Fri Mar 27 13:11:29 2009
New Revision: 145104

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145104
Log:
gcc/cp/

2009-03-27  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/29727
	* decl.c (check_array_designated_initializer): Handle error_mark_node.

gcc/testsuite/

2009-03-27  Simon Martin  <simartin@users.sourceforge.net>

	PR c++/29727
	* g++.dg/init/error2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/init/error2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 11 Joseph S. Myers 2009-03-31 20:06:22 UTC
Closing 4.2 branch.
Comment 12 Richard Biener 2009-04-22 15:23:10 UTC
WONTFIX for 4.3.