Bug 14401 - [3.3 regression] Uninitialized reference error not reported.
Summary: [3.3 regression] Uninitialized reference error not reported.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.3.4
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2004-03-03 08:37 UTC by Gerhard Wesp
Modified: 2004-10-07 03:31 UTC (History)
2 users (show)

See Also:
Host: Suse Linux 9.0
Target:
Build:
Known to work: 2.95.3 3.2.3 3.4.0 4.0.0
Known to fail: 3.3.4
Last reconfirmed: 2004-03-03 15:41:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Wesp 2004-03-03 08:37:29 UTC
G++ erroneously compiles this code:

  struct { struct { int& i ; } bar ; } foo ;

which should caues an error because the implicitly generated 
constructor for foo.bar cannot initialize foo.bar.i .
Comment 1 Wolfgang Bangerth 2004-03-03 15:41:00 UTC
Confirmed. Not even a warning is given with -W -Wall. 
 
This is a regression in 3.3, 3.4 and mainline, because up to 3.2 
we get this: 
g/x> /home/bangerth/bin/gcc-3.2*/bin/c++ -c x.cc -W -Wall -Wunused 
x.cc:1: warning: non-static reference `int&<anonymous struct>::<anonymous  
   struct>::i' in class without a constructor 
 
 
W. 
Comment 2 Giovanni Bajo 2004-03-03 18:40:30 UTC
The code is actually ill-formed.
Comment 3 GCC Commits 2004-03-09 07:27:29 UTC
Subject: Bug 14401

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-03-09 07:27:26

Modified files:
	gcc/cp         : ChangeLog class.c init.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/ext: anon-struct4.C 
	gcc/testsuite/g++.dg/init: ctor3.C union1.C 

Log message:
	PR c++/14401
	* class.c (check_field_decls): Complain about non-static data
	members of reference type in unions.  Propagate
	CLASSTYPE_REF_FIELDS_NEED_INIT and
	CLASSTYPE_READONLY_FIELDS_NEED_INIT from the types of non-static
	data members.
	* init.c (perform_member_init): Complain about mbmers with const
	type that are not explicitly initialized.
	
	PR c++/14401
	* g++.dg/init/ctor3.C: New test.
	* g++.dg/init/union1.C: New test.
	* g++.dg/ext/anon-struct4.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.72&r2=1.3892.2.73
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.6&r2=1.595.4.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.356.2.6&r2=1.356.2.7
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.131&r2=1.3389.2.132
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/anon-struct4.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/init/ctor3.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/init/union1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 4 GCC Commits 2004-03-09 08:16:54 UTC
Subject: Bug 14401

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-03-09 08:16:49

Modified files:
	gcc/cp         : ChangeLog class.c cp-tree.h decl.c init.c lex.c 
	                 name-lookup.c name-lookup.h ptree.c search.c 
	                 typeck.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/lookup: koenig1.C used-before-declaration.C 
	gcc/testsuite/g++.dg/other: do1.C 
	gcc/testsuite/g++.dg/overload: koenig1.C 
	gcc/testsuite/g++.dg/parse: crash13.C 
	gcc/testsuite/g++.dg/template: instantiate3.C 
Added files:
	gcc/testsuite/g++.dg/ext: anon-struct4.C 
	gcc/testsuite/g++.dg/init: ctor3.C union1.C 

Log message:
	PR c++/14401
	* class.c (check_field_decls): Complain about non-static data
	members of reference type in unions.  Propagate
	CLASSTYPE_REF_FIELDS_NEED_INIT and
	CLASSTYPE_READONLY_FIELDS_NEED_INIT from the types of non-static
	data members.
	* init.c (perform_member_init): Complain about mbmers with const
	type that are not explicitly initialized.
	
	PR c++/14401
	* g++.dg/init/ctor3.C: New test.
	* g++.dg/init/union1.C: New test.
	* g++.dg/ext/anon-struct4.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3987&r2=1.3988
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.602&r2=1.603
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.955&r2=1.956
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1192&r2=1.1193
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.363&r2=1.364
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/lex.c.diff?cvsroot=gcc&r1=1.325&r2=1.326
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.43&r2=1.44
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.h.diff?cvsroot=gcc&r1=1.18&r2=1.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ptree.c.diff?cvsroot=gcc&r1=1.38&r2=1.39
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&r1=1.287&r2=1.288
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.530&r2=1.531
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3583&r2=1.3584
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/anon-struct4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ctor3.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/union1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/koenig1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/used-before-declaration.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/other/do1.C.diff?cvsroot=gcc&r1=1.3&r2=1.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/overload/koenig1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/crash13.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/instantiate3.C.diff?cvsroot=gcc&r1=1.2&r2=1.3

Comment 5 Mark Mitchell 2004-03-09 08:20:06 UTC
Fixed in GCC 3.4 and GCC 3.5.
Comment 6 GCC Commits 2004-03-13 02:31:50 UTC
Subject: Bug 14401

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	gdr@gcc.gnu.org	2004-03-13 02:31:37

Modified files:
	gcc/cp         : ChangeLog class.c init.c 
Added files:
	gcc/testsuite/g++.dg/ext: anon-struct4.C 
	gcc/testsuite/g++.dg/init: ctor3.C union1.C 

Log message:
	Backport:
	2004-03-08  Mark Mitchell  <mark@codesourcery.com>
	PR c++/14401
	* class.c (check_field_decls): Complain about non-static data
	members of reference type in unions.  Propagate
	CLASSTYPE_REF_FIELDS_NEED_INIT and
	CLASSTYPE_READONLY_FIELDS_NEED_INIT from the types of
	non-static
	data members.
	* init.c (perform_member_init): Complain about members with const
	type that are not explicitly initialized.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.261&r2=1.3076.2.262
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.499.2.27&r2=1.499.2.28
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.299.2.15&r2=1.299.2.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/anon-struct4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.2.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/ctor3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.2.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/union1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.2.2.1

Comment 7 Gabriel Dos Reis 2004-03-13 02:33:25 UTC
http://gcc.gnu.org/ml/gcc-patches/2004-03/msg01091.html