Bug 33839 - [4.3 regression] ICE with decltype
Summary: [4.3 regression] ICE with decltype
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2007-10-20 21:49 UTC by Volker Reichelt
Modified: 2007-12-02 22:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2007-10-20 21:49:59 UTC
The following code snippet triggers an ICE on mainline
(I'm not sure whether this is valid or not):

===============================
template<int> struct A;

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

bug5.cc: In function 'void foo()':
bug5.cc:9: internal compiler error: in cp_parser_lookup_name, at cp/parser.c:16084
Please submit a full bug report, [etc.]

The problem appeared between 2007-07-16 and 2007-08-15, presumably with
the introduction of decltype:

2007-07-27  Douglas Gregor  <doug.gregor@gmail.com>

	* typeck.c (structural_comptypes): Compare DECLTYPE_TYPE nodes.
	* cp-tree.def (DECLTYPE_TYPE): New.
	* error.c (dump_type): Dump DECLTYPE_TYPE nodes.
        ...
Comment 1 Wolfgang Bangerth 2007-10-20 23:36:03 UTC
The code should be invalid precisely because this is also invalid:
-------------------
template<int> struct A;

void foo()
{
  A<0>;
}
-------------------

g/x> c++ -c x.cc
x.cc: In function 'void foo()':
x.cc:5: error: declaration does not declare anything

W.
Comment 2 dgregor 2007-10-26 17:54:07 UTC
Subject: Bug 33839

Author: dgregor
Date: Fri Oct 26 17:53:56 2007
New Revision: 129656

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129656
Log:
2007-10-26  Douglas Gregor  <doug.gregor@gmail.com>

	PR c++/33839
	* parser.c (cp_parser_decltype): Return ERROR_MARK_NODE if we
	don't see the leading '('. Only lookup names if we get an
	IDENTIFIER_NODE.

2007-10-26  Douglas Gregor  <doug.gregor@gmail.com>

	* g++.dg/cpp0x/pr33839.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr33839.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 dgregor 2007-10-26 18:01:41 UTC
Fixed. The testcase is invalid code, but we shouldn't crash on it. Now we don't.
Comment 4 dgregor 2007-10-26 18:36:44 UTC
*** Bug 33837 has been marked as a duplicate of this bug. ***
Comment 5 dgregor 2007-10-26 18:38:16 UTC
*** Bug 33838 has been marked as a duplicate of this bug. ***