This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Uninitialized reference member should cause an error.


>Submitter-Id:	net
>Originator:	Gerhard Wesp
>Confidential:	no
>Synopsis:	Uninitialized reference member should cause an error.
>Severity:	non-critical
>Priority:	medium
>Category:	c++
>Class:		accepts-illegal
>Release:	3.3.1 (SuSE Linux)
>Environment:
System: Linux ventus 2.4.21-166-smp4G #1 SMP Fri Dec 19 15:43:30 UTC 2003 i686 i686 i386 GNU/Linux
Architecture: i686

	
host: i586-suse-linux-gnu
build: i586-suse-linux-gnu
target: i586-suse-linux-gnu
configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --disable-checking --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux
>Description:
G++ accepts reference members without initialization.
>How-To-Repeat:
~% cat repeat.cpp ten                                  

struct foo { struct bar { int& x ; } ; bar y ; } ;
foo::bar f() { foo x ; return x.y ; }

~% g++ -Wall -c repeat.cpp
~% 
[File compiles OK]

I think this is an error, because the compiler-generated default
constructor for foo::bar cannot initialize foo::bar::x.  Comeau online
is of the same opinion.

Should this be legal, IMHO at least a warning should be produced!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]