[Bug c++/18635] New: use of uninitialised reference accepted in C++ front end
ajo at acm dot org
gcc-bugzilla@gcc.gnu.org
Tue Nov 23 23:11:00 GMT 2004
The following (presumably invalid) code is compiled successfully:
int main(void)
{
int &a = a;
printf("a = %d\n", a);
return 0;
}
albeit with the following warning (if given -Wall -W):
foo.cc: In function `int main()':
foo.cc:5: warning: 'a' might be used uninitialized in this function
The generated assembly is as follows:
main()
1070c: 9d e3 bf 90 save %sp, -0x70, %sp
10710: 11 00 00 41 sethi %hi(0x10400), %o0
10714: 90 12 23 c0 or %o0, 0x3c0, %o0 ! 0x107c0
10718: 40 00 40 54 call printf
1071c: d2 02 40 00 ld [%o1], %o1
10720: 81 c7 e0 08 ret
10724: 91 e8 20 00 restore %g0, 0x0, %o0
Given that the reference above is never bound to any valid object, should this
instead error?
Tested on 3.4.0 and 3.4.3 (both behave identically).
--
Summary: use of uninitialised reference accepted in C++ front end
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ajo at acm dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: sparc-sun-solaris2.9
GCC host triplet: sparc-sun-solaris2.9
GCC target triplet: sparc-sun-solaris2.9
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
More information about the Gcc-bugs
mailing list