GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 23797 - [3.4 Regression] ICE on typename outside template
Summary: [3.4 Regression] ICE on typename outside template
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 3.4.5
Assignee: Volker Reichelt
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-invalid-code, monitored, patch
: 24200 25744 26665 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-09 14:40 UTC by Sylvain Pion
Modified: 2006-03-13 15:02 UTC (History)
7 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work: 3.3.3 4.0.3 4.1.0 4.2.0
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2005-10-12 13:05:50


Attachments
gzipped .ii c++ file (299.54 KB, application/octet-stream)
2005-09-09 14:41 UTC, Sylvain Pion
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Pion 2005-09-09 14:40:43 UTC
The attached preprocessed file compiled with g++ produces the ICE :

include/CGAL/_test_circles_constructions.h: In function 'void
_test_circle_construct(CK2)':
include/CGAL/_test_circles_constructions.h:294: internal compiler error:
Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

----------------

I have not found the time to simplify/shorten it, but I believe that there is
an invalid use of "typename" in the program.  Removing this typename makes
the compiler happy.
Comment 1 Sylvain Pion 2005-09-09 14:41:58 UTC
Created attachment 9702 [details]
gzipped .ii c++ file
Comment 2 Andrew Pinski 2005-09-09 16:24:57 UTC
reducing.
Comment 3 Andrew Pinski 2005-09-09 23:10:06 UTC
It took me a while to reduce this but finally:
struct CK {
  typedef int RT;
};
void f(void)
{
  2 / typename CK::RT(2);
}
Comment 4 Volker Reichelt 2005-09-11 15:58:01 UTC
Even shorter testcase:

================================
struct A { typedef int X; };

int i = typename A::X();
================================
Comment 5 Andrew Pinski 2005-09-12 20:43:40 UTC
: Search converges between 2004-03-01-trunk (#446) and 2004-04-01-trunk (#447).

: Search converges between 2004-03-15-3.4 (#3) and 2004-04-01-3.4 (#4).
Comment 6 Janis Johnson 2005-09-16 18:08:35 UTC
The ICE begins on mainline with this patch from giovannibajo:

  http://gcc.gnu.org/ml/gcc-cvs/2004-03/msg00874.html
Comment 7 Andrew Pinski 2005-10-04 21:01:01 UTC
*** Bug 24200 has been marked as a duplicate of this bug. ***
Comment 8 CVS Commits 2005-10-12 18:07:46 UTC
Subject: Bug 23797

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	nathan@gcc.gnu.org	2005-10-12 18:07:44

Modified files:
	gcc/cp         : ChangeLog parser.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: typename8.C 

Log message:
	cp:
	PR c++/23797
	* parser.c (cp_parser_functional_cast): Cope when TYPE is not a
	TYPE_DECL.  Use dependent_type_p to check type.
	* pt.c (uses_template_parms_p): Use dependent_type_p for a
	TYPE_DECL.
	(type_dependent_expression_p): Assert we've not been given a
	TYPE_DECL.
	testsuite:
	PR c++/23797
	* g++.dg/other/typename8.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4925&r2=1.4926
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.363&r2=1.364
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.1043&r2=1.1044
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6177&r2=1.6178
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/typename8.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 9 CVS Commits 2005-10-12 18:23:24 UTC
Subject: Bug 23797

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	nathan@gcc.gnu.org	2005-10-12 18:23:17

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog pt.c typeck.c parser.c decl.c 
Added files:
	gcc/testsuite/g++.dg/other: return1.C 
	gcc/testsuite/g++.dg/parse: typename8.C 
	gcc/testsuite/g++.dg/template: overload6.C 

Log message:
	cp:
	PR c++/21592
	* pt.c (build_non_dependent_expr): Don't wrap a COMPONENT_REF
	with already looked up member functions.  Assert we're not
	returning a NON_DEPENDENT_EXPR with unknown type.
	* typeck.c (finish_class_member_access_expr):  We can get
	non-template-id-expr baselinks.  If the lookup finds a baselink,
	remember it even inside templates.
	
	PR c++/23797
	* parser.c (cp_parser_functional_cast): Cope when TYPE is not a
	TYPE_DECL.  Use dependent_type_p to check type.
	* pt.c (uses_template_parms_p): Use dependent_type_p for a
	TYPE_DECL.
	(type_dependent_expression_p): Assert we've not been given a
	TYPE_DECL.
	
	PR c++/21117
	* decl.c (check_function_type): Correctly overwrite incomplete
	return type with void type.
	* typeck.c (check_return_expr): If the function's return type is
	void, don't try and convert a return expr.
	testsuite:
	PR c++/21592
	* g++.dg/template/dependent-expr1.C: Add new expected error.
	* g++.dg/template/dependent-expr2.C: Adjust error text.
	* g++.dg/template/overload6.C: New.
	
	PR c++/23797
	* g++.dg/other/typename8.C: New.
	
	PR c++/21117
	* g++.dg/other/return1.C: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/return1.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/typename8.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/overload6.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
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.450&r2=1.5084.2.451
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.127&r2=1.4648.2.128
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.30&r2=1.978.2.31
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.616.2.20&r2=1.616.2.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.319.2.22&r2=1.319.2.23
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1371.2.24&r2=1.1371.2.25

Comment 10 Nathan Sidwell 2005-10-12 18:23:51 UTC
Fixed mainline and 4.0
2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/23797
	* parser.c (cp_parser_functional_cast): Cope when TYPE is not a
	TYPE_DECL.  Use dependent_type_p to check type.
	* pt.c (uses_template_parms_p): Use dependent_type_p for a
	TYPE_DECL.
	(type_dependent_expression_p): Assert we've not been given a
	TYPE_DECL.
Comment 11 Andrew Pinski 2005-10-12 18:57:53 UTC
Fixed.
Comment 12 Nathan Sidwell 2005-10-13 13:14:27 UTC
probably should be backported to 3.4
Comment 13 Volker Reichelt 2005-10-14 10:54:28 UTC
Changin to ice-on-valid-code, because Nathan stated in the patch
http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00712.html

> Note, we do not issue an error on the testcase, even though it uses typename outside of a
> template. DR 382 (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#382), which
> is in ready status, will allow such uses, so it seems silly to me to become strict only to
> have to remove the strictness later.
Comment 14 Volker Reichelt 2005-11-03 11:29:39 UTC
Since Mark's patch for PR19253
http://gcc.gnu.org/ml/gcc-patches/2005-11/msg00141.html
this is an error again.
Comment 15 Volker Reichelt 2005-11-16 01:24:16 UTC
Taking care of the backport to the 3.4 branch.
Comment 16 Volker Reichelt 2005-11-16 13:03:19 UTC
Subject: Bug 23797

Author: reichelt
Date: Wed Nov 16 13:03:13 2005
New Revision: 107081

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107081
Log:
	Backport from mainline:
	2005-10-12  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/23797
	* parser.c (cp_parser_functional_cast): Cope when TYPE is not a
	TYPE_DECL.  Use dependent_type_p to check type.
	* pt.c (uses_template_parms_p): Use dependent_type_p for a
	TYPE_DECL.
	(type_dependent_expression_p): Assert we've not been given a
	TYPE_DECL.

	* g++.dg/parse/typename8.C: New test.
	* g++.dg/parse/typename9.C: Likewise.


Added:
    branches/gcc-3_4-branch/gcc/testsuite/g++.dg/parse/typename8.C
    branches/gcc-3_4-branch/gcc/testsuite/g++.dg/parse/typename9.C
Modified:
    branches/gcc-3_4-branch/gcc/cp/ChangeLog
    branches/gcc-3_4-branch/gcc/cp/parser.c
    branches/gcc-3_4-branch/gcc/cp/pt.c
    branches/gcc-3_4-branch/gcc/testsuite/ChangeLog

Comment 17 Volker Reichelt 2005-11-16 13:05:01 UTC
Now also fixed on the 3.4 branch.
Comment 18 Andrew Pinski 2006-01-10 22:40:13 UTC
*** Bug 25744 has been marked as a duplicate of this bug. ***
Comment 19 Andrew Pinski 2006-03-13 15:02:19 UTC
*** Bug 26665 has been marked as a duplicate of this bug. ***