This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/18635] New: use of uninitialised reference accepted in C++ front end
- From: "ajo at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Nov 2004 23:11:15 -0000
- Subject: [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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