Bug 28420 - [4.1 regression] ICE with "typeid" as template parameter
Summary: [4.1 regression] ICE with "typeid" as template parameter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P4 minor
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-07-18 10:42 UTC by Volker Reichelt
Modified: 2008-07-04 15:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.0
Known to fail: 4.0.4 4.1.3
Last reconfirmed: 2006-09-03 05:37:25


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-07-18 10:42:46 UTC
The following invalid code snippet triggers an ICE since GCC 4.0.0:

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

int i = sizeof(A<typeid>);
========================================

bug.cc:3: error: `typeid' operator cannot appear in a constant-expression
bug.cc:3: error: template argument 1 is invalid
*** glibc detected *** double free or corruption (out): 0x00000000009e51c0 ***
bug.cc:3: internal compiler error: Aborted
Please submit a full bug report, [etc.]
Comment 1 patchapp@dberlin.org 2006-08-19 07:31:07 UTC
Subject: Bug number PR c++/28420

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-08/msg00700.html
Comment 2 Jason Merrill 2006-08-22 18:51:56 UTC
Subject: Bug 28420

Author: jason
Date: Tue Aug 22 18:51:40 2006
New Revision: 116330

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116330
Log:
        PR c++/28420
        * parser.c (cp_parser_postfix_expression): Make sure that the
        saved value for parser->type_definition_forbidden_message is
        restored before returning to avoid an invalid free().

Added:
    trunk/gcc/testsuite/g++.dg/template/typeid-template-argument.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c

Comment 3 Gabriel Dos Reis 2007-02-03 18:02:55 UTC
Won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 4 Joseph S. Myers 2008-07-04 15:43:30 UTC
Closing 4.1 branch.