Uninitialized reference member should cause an error.
gwesp@flyelite.ch
gwesp@flyelite.ch
Fri Feb 27 11:51:00 GMT 2004
>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!
More information about the Gcc-bugs
mailing list