Bug 17524 - [3.3/3.4/4.0 regression] ICE with initializing a variable of type void
Summary: [3.3/3.4/4.0 regression] ICE with initializing a variable of type void
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 3.4.3
Assignee: Mark Mitchell
URL:
Keywords: error-recovery, ice-checking, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2004-09-16 16:30 UTC by Wolfgang Bangerth
Modified: 2004-10-09 17:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3
Known to fail: 3.0 3.4.2 4.0.0
Last reconfirmed: 2004-09-16 19:58:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2004-09-16 16:30:55 UTC
Spinoff from PR 17344: 
---------------------------------- 
template <typename T> struct intTraits { 
    static const T i = 0; 
}; 
 
struct S { 
    S(intTraits<void>); 
}; 
 
template <typename> struct A {}; 
 
int bar(S); 
int bar(A<int>); 
 
S *s; 
int i = bar(*s); 
------------------------ 
 
We shouldn't ICE here: 
g/x> /home/bangerth/bin/gcc-4.0-pre/bin/c++ -c x.cc 
x.cc: In instantiation of `intTraits<void>': 
x.cc:15:   instantiated from here 
x.cc:2: error: instantiation of `intTraits<void>::i' as type `const void' 
x.cc:2: error: `intTraits<void>::i' has incomplete type 
x.cc:2: error: invalid in-class initialization of static data member of 
non-integral type `<type error>' 
x.cc:1: internal compiler error: tree check: expected class 't', have 
'x' (error_mark) in finish_struct_1, at cp/class.c:5065 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
W.
Comment 1 Volker Reichelt 2004-09-16 19:58:55 UTC
Here's something shorter:

==============================
template<typename T> struct A
{
    static const T i;
};

A<void> a;
==============================

We ICE since gcc 3.0.
Comment 2 Volker Reichelt 2004-10-03 23:58:33 UTC
Sorry, I meant of course:

=============================
template<typename T> struct A
{
    static const T i = 0;
};

A<void> a;
=============================
Comment 3 GCC Commits 2004-10-09 17:33:08 UTC
Subject: Bug 17524

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-10-09 17:33:02

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog cp-tree.h decl.c pt.c 
Added files:
	gcc/testsuite/g++.dg/parse: operator5.C 
	gcc/testsuite/g++.dg/template: static9.C 

Log message:
	PR c++/17524
	* cp-tree.h (check_var_type): New function.
	* decl.c (check_var_type): New function, split out from ...
	(grokdeclarator): ... here.
	* pt.c (tsubst_decl): Use check_var_type.
	
	PR c++/17685
	* decl.c (grokdeclarator): Disallow declarations of operators as
	
	PR c++/17524
	* g++.dg/template/static9.C: New test.
	
	PR c++/17685
	* g++.dg/parse/operator5.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4419&r2=1.4420
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4415&r2=1.4416
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1058&r2=1.1059
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1311&r2=1.1312
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.933&r2=1.934
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/operator5.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/static9.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 4 GCC Commits 2004-10-09 17:55:35 UTC
Subject: Bug 17524

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-10-09 17:55:31

Modified files:
	gcc/cp         : ChangeLog cp-tree.h decl.c pt.c 
Added files:
	gcc/testsuite/g++.dg/parse: operator5.C 
	gcc/testsuite/g++.dg/template: static9.C 

Log message:
	PR c++/17524
	* cp-tree.h (check_var_type): New function.
	* decl.c (check_var_type): New function, split out from ...
	(grokdeclarator): ... here.
	* pt.c (tsubst_decl): Use check_var_type.
	
	PR c++/17685
	* decl.c (grokdeclarator): Disallow declarations of operators as
	non-functions.
	
	PR c++/17524
	* g++.dg/template/static9.C: New test.
	
	PR c++/17685
	* g++.dg/parse/operator5.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.164&r2=1.3892.2.165
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.946.4.16&r2=1.946.4.17
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.24&r2=1.1174.2.25
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.42&r2=1.816.2.43
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/operator5.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/static9.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 5 Mark Mitchell 2004-10-09 17:57:38 UTC
Fixed in GCC 3.4.3.