Bug 22603 - [4.0 Regression] ICE in pop_binding, at cp/name-lookup.c:380
Summary: [4.0 Regression] ICE in pop_binding, at cp/name-lookup.c:380
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.1
: P2 normal
Target Milestone: 4.0.3
Assignee: Nathan Sidwell
URL:
Keywords: error-recovery, ice-on-invalid-code, ice-on-valid-code, monitored
Depends on:
Blocks:
 
Reported: 2005-07-22 02:30 UTC by Flash Sheridan
Modified: 2005-10-14 16:02 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 3.4.4 4.0.0 4.1.0
Known to fail: 4.0.1
Last reconfirmed: 2005-10-13 11:51:34


Attachments
104911_HtmlView_min.ii (152 bytes, text/plain)
2005-07-22 02:32 UTC, Flash Sheridan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Flash Sheridan 2005-07-22 02:30:23 UTC
The invalid code below results in "internal compiler error: in pop_binding, at cp/name-lookup.c:380" 
with a checking version of GCC 4.0.1.  Does not happen with GCC 3.3.4.

class NameOne : public static_small_value
{
 inline NameOne(T v) {
 }
{
};
template<class KEY, class VALUE>
class NameTwo : private NameThree
{
    void NameFour(const struct NameFive &cache);

This code is a greatly-reduced (and anonymized) excerpt, found by Daniel Wilkerson's Delta, from some 
real PalmSource code; I'm not sure it makes any sense at all.  The original code seemed to give a 
different compiler error, which I'll try to file separately; though it involves 16K lines of proprietary code, 
so it may have to wait for our CodeSourcery support agreement.

===========
Session:
117> /opt/gcc401chk/bin/g++ -v  /Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/
104911_HtmlView_min.ii
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure --enable-checking --prefix=/opt/gcc401chk --enable-languages=c,c+
+
Thread model: posix
gcc version 4.0.1
 /opt/gcc401chk/libexec/gcc/i686-pc-linux-gnu/4.0.1/cc1plus -fpreprocessed /Projects/
PlatformTools/compilerChain/tests/cpp/bugfiles/error/104911_HtmlView_min.ii -quiet -dumpbase 
104911_HtmlView_min.ii -mtune=pentiumpro -auxbase 104911_HtmlView_min -version -o /tmp/
ccKTKYmH.s
GNU C++ version 4.0.1 (i686-pc-linux-gnu)
        compiled by GNU C version 3.3.4 (pre 3.3.5 20040809).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/104911_HtmlView_min.ii:2: error: 
expected class-name before ‘{’ token
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/104911_HtmlView_min.ii:3: error: 
expected `)' before ‘v’
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/104911_HtmlView_min.ii:5: error: 
expected unqualified-id before ‘{’ token
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/104911_HtmlView_min.ii:9: error: 
expected class-name before ‘{’ token
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/104911_HtmlView_min.ii:10: error: 
expected `}' at end of input
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/104911_HtmlView_min.ii:10: error: 
expected unqualified-id at end of input
/Projects/PlatformTools/compilerChain/tests/cpp/bugfiles/error/104911_HtmlView_min.ii:10: internal 
compiler error: in pop_binding, at cp/name-lookup.c:380
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


PalmSource bug 104911
Comment 1 Flash Sheridan 2005-07-22 02:32:11 UTC
Created attachment 9326 [details]
104911_HtmlView_min.ii
Comment 2 Flash Sheridan 2005-07-22 02:35:10 UTC
This sounds like bugs 9777 and 5402, but those were supposedly fixed.
Comment 3 Andrew Pinski 2005-07-22 02:43:47 UTC
Confirmed, only a 4.0 regression.  We do not get an ICE on the mainline.
Comment 4 Andrew Pinski 2005-07-22 04:00:45 UTC
I should mention this was started after 20050225 which was when the branch happened.
And here is the backtrace:
#0  fancy_abort (file=0x1197880 "../../gcc/cp/name-lookup.c", line=380, function=0x1197904 
"pop_binding") at ../../gcc/diagnostic.c:556
#1  0x001e83d0 in pop_binding (id=0x426b923c, decl=0x426b5e80) at ../../gcc/cp/name-lookup.c:
380
#2  0x00028968 in poplevel (keep=0, reverse=0, functionbody=0) at ../../gcc/cp/decl.c:650
#3  0x0002707c in finish_scope () at ../../gcc/cp/decl.c:346
#4  0x00079c34 in end_template_decl () at ../../gcc/cp/pt.c:2400
#5  0x001b6e1c in finish_template_decl (parms=0x4267c300) at ../../gcc/cp/semantics.c:2300
#6  0x00147594 in cp_parser_template_declaration_after_export (parser=0x426b92a4, member_p=1 
'\001') at ../../gcc/cp/parser.c:15038
#7  0x0013a240 in cp_parser_template_declaration (parser=0x426b92a4, member_p=1 '\001') at ../../
gcc/cp/parser.c:8154
#8  0x001436bc in cp_parser_member_declaration (parser=0x426b92a4) at ../../gcc/cp/parser.c:
13099
#9  0x00143624 in cp_parser_member_specification_opt (parser=0x426b92a4) at ../../gcc/cp/
parser.c:13040
#10 0x00141dc4 in cp_parser_class_specifier (parser=0x426b92a4) at ../../gcc/cp/parser.c:12498
#11 0x0013c8e4 in cp_parser_type_specifier (parser=0x426b92a4, 
flags=CP_PARSER_FLAGS_OPTIONAL, decl_specs=0xbffff840, is_declaration=1 '\001', 
declares_class_or_enum=0xbffff7d8, is_cv_qualifier=0xbffff7dc "") at ../../gcc/cp/parser.c:9326
#12 0x00138d18 in cp_parser_decl_specifier_seq (parser=0x426b92a4, 
flags=CP_PARSER_FLAGS_OPTIONAL, decl_specs=0xbffff840, declares_class_or_enum=0xbffff890) at ../
../gcc/cp/parser.c:7309
#13 0x00138714 in cp_parser_simple_declaration (parser=0x426b92a4, 
function_definition_allowed_p=1 '\001') at ../../gcc/cp/parser.c:7005
#14 0x001386b8 in cp_parser_block_declaration (parser=0x426b92a4, statement_p=0 '\0') at ../../
gcc/cp/parser.c:6966
#15 0x001384a0 in cp_parser_declaration (parser=0x426b92a4) at ../../gcc/cp/parser.c:6883
#16 0x001380fc in cp_parser_declaration_seq_opt (parser=0x426b92a4) at ../../gcc/cp/parser.c:6787
#17 0x00130d8c in cp_parser_translation_unit (parser=0x426b92a4) at ../../gcc/cp/parser.c:2596
Comment 5 Volker Reichelt 2005-07-25 12:58:55 UTC
Here's a similar example with valid code:

========================================
struct A
{
    template<int> struct B
    {
        void foo(const struct C&);
    };
};
========================================

GCC 4.0.0 is not affected - the problem was introduced between 4.0.0 and 4.0.1.
Comment 6 GCC Commits 2005-10-14 16:00:34 UTC
Subject: Bug 22603

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	nathan@gcc.gnu.org	2005-10-14 16:00:25

Modified files:
	gcc/cp         : ChangeLog name-lookup.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: template18.C 

Log message:
	cp:
	PR c++/22603
	Backport part of
	2005-03-14  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
	* name-lookup.c (pushtag): Skip template parameter scope when
	scope is ts_global.  Don't push tag into template parameter
	scope.
	testsuite:
	PR c++/22603
	* g++.dg/parse/template18.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.132&r2=1.4648.2.133
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.109.4.9&r2=1.109.4.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.456&r2=1.5084.2.457
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/template18.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 7 Nathan Sidwell 2005-10-14 16:02:13 UTC
2005-10-14  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/22603
	Backport part of
	2005-03-14  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
	* name-lookup.c (pushtag): Skip template parameter scope when
	scope is ts_global.  Don't push tag into template parameter
	scope.