Bug 15427 - [3.4/4.0 regression] valid code results in incomplete type error
Summary: [3.4/4.0 regression] valid code results in incomplete type error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2004-05-13 20:59 UTC by nick
Modified: 2004-10-30 21:11 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.3.3
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-05-13 21:04:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nick 2004-05-13 20:59:21 UTC
The following code:

template<class T>
struct A
{
    T foo;
};

template<class T>
struct B
{
    A<int> _squares[2];
};

results in:

>/dept/rnd/vendor/gcc-3.4.0/bin/g++ -c testCornerFinder.C
testCornerFinder.C:10: error: field `_squares' has incomplete type

with gcc-3.4.  gcc-3.3 compiles this code correctly.  The code
also compiles if the [2] is removed.

-nick
Comment 1 Andrew Pinski 2004-05-13 21:04:52 UTC
Confirmed.
Comment 2 Wolfgang Bangerth 2004-05-13 23:24:07 UTC
Indeed, how surprising. Giovanni, wasn't it you who was working on 
incomplete type diagnostics? 
 
W. 
Comment 3 Giovanni Bajo 2004-05-15 00:04:26 UTC
(In reply to comment #2)

> Indeed, how surprising. Giovanni, wasn't it you who was working on 
> incomplete type diagnostics? 

Yes, but this is unrelated to the work I did.
Comment 4 Mark Mitchell 2004-05-22 18:09:41 UTC
Working on a fix.
Comment 5 GCC Commits 2004-05-22 19:17:08 UTC
Subject: Bug 15427

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-05-22 19:16:53

Modified files:
	gcc/cp         : ChangeLog class.c typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/inherit: union1.C 
	gcc/testsuite/g++.dg/template: addr1.C array5.C array6.C 

Log message:
	PR c++/15507
	* g++.dg/inherit/union1.C: New test.
	
	PR c++/15542
	* g++.dg/template/addr1.C: New test.
	
	PR c++/15427
	* g++.dg/template/array5.C: New test.
	
	PR c++/15287
	* g++.dg/template/array6.C: New test.
	
	PR c++/15507
	* g++.dg/inherit/union1.C: New test.
	
	PR c++/15542
	* g++.dg/template/addr1.C: New test.
	
	PR c++/15427
	* g++.dg/template/array5.C: New test.
	
	PR c++/15287
	* g++.dg/template/array6.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.100&r2=1.3892.2.101
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.595.4.7&r2=1.595.4.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.519.2.14&r2=1.519.2.15
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.177&r2=1.3389.2.178
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/union1.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/addr1.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/array5.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/array6.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 6 GCC Commits 2004-05-22 19:28:41 UTC
Subject: Bug 15427

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-05-22 19:28:31

Modified files:
	gcc/cp         : ChangeLog class.c typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/inherit: union1.C 
	gcc/testsuite/g++.dg/template: addr1.C array5.C array6.C 

Log message:
	PR c++/15507
	* class.c (layout_nonempty_base_or_field): Do not try to avoid
	layout conflicts for unions.
	
	PR c++/15542
	* typeck.c (build_x_unary_op): Instantiate template class
	specializations before looking for "operator &".
	
	PR c++/15427
	* typeck.c (complete_type): Layout non-dependent array types, even
	in templates.
	
	PR c++/15287
	* typeck.c (build_unary_op): Do not optimize "&x[y]" when in a
	template.
	
	PR c++/15507
	* g++.dg/inherit/union1.C: New test.
	
	PR c++/15542
	* g++.dg/template/addr1.C: New test.
	
	PR c++/15427
	* g++.dg/template/array5.C: New test.
	
	PR c++/15287
	* g++.dg/template/array6.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4050&r2=1.4051
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.612&r2=1.613
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.542&r2=1.543
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3769&r2=1.3770
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/union1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/addr1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/array5.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/array6.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 7 Mark Mitchell 2004-05-22 19:30:59 UTC
Fixed in GCC 3.4.1.