public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end
@ 2004-11-23 23:11 ajo at acm dot org
2004-11-23 23:19 ` [Bug c++/18635] " pinskia at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: ajo at acm dot org @ 2004-11-23 23:11 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/18635] use of uninitialised reference accepted in C++ front end
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
@ 2004-11-23 23:19 ` pinskia at gcc dot gnu dot org
2004-11-24 2:11 ` llib at computer dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-23 23:19 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/18635] use of uninitialised reference accepted in C++ front end
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
2004-11-23 23:19 ` [Bug c++/18635] " pinskia at gcc dot gnu dot org
@ 2004-11-24 2:11 ` llib at computer dot org
2004-11-24 19:07 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: llib at computer dot org @ 2004-11-24 2:11 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |llib at computer dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/18635] use of uninitialised reference accepted in C++ front end
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
2004-11-23 23:19 ` [Bug c++/18635] " pinskia at gcc dot gnu dot org
2004-11-24 2:11 ` llib at computer dot org
@ 2004-11-24 19:07 ` pinskia at gcc dot gnu dot org
2004-11-26 2:56 ` llib at computer dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-24 19:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-11-24 19:07 -------
No this is valid code (but undefined):
int &a = a;
a is injected before the equals so the code is about the same as:
int *a = &*a;
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/18635] use of uninitialised reference accepted in C++ front end
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
` (2 preceding siblings ...)
2004-11-24 19:07 ` pinskia at gcc dot gnu dot org
@ 2004-11-26 2:56 ` llib at computer dot org
2004-11-26 10:17 ` giovannibajo at libero dot it
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: llib at computer dot org @ 2004-11-26 2:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From llib at computer dot org 2004-11-26 02:56 -------
int &a = a;
i don't believe this is valid code. i believe g++ should reject the code.
various comp.std.c++ people agree with me.
8.3.2/4 states "[...] A reference shall be initialized to refer to a valid
object or function."
surely a (the right-hand-side) is not a valid object or function since it has
not been initialised, so the code is ill-formed.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/18635] use of uninitialised reference accepted in C++ front end
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
` (3 preceding siblings ...)
2004-11-26 2:56 ` llib at computer dot org
@ 2004-11-26 10:17 ` giovannibajo at libero dot it
2004-11-29 0:56 ` llib at computer dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-26 10:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-26 10:16 -------
Do you have a comp.std.c++ link?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/18635] use of uninitialised reference accepted in C++ front end
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
` (4 preceding siblings ...)
2004-11-26 10:17 ` giovannibajo at libero dot it
@ 2004-11-29 0:56 ` llib at computer dot org
2004-11-29 11:26 ` giovannibajo at libero dot it
2004-11-29 11:41 ` giovannibajo at libero dot it
7 siblings, 0 replies; 9+ messages in thread
From: llib at computer dot org @ 2004-11-29 0:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From llib at computer dot org 2004-11-29 00:54 -------
google groups link to discussion:
<http://groups.google.com/groups?hl=en&lr=&th=6d093e6073eaac16&seekm=fcaee77e.0411251120.6a6ad93b%40posting.google.com&frame=off>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/18635] use of uninitialised reference accepted in C++ front end
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
` (5 preceding siblings ...)
2004-11-29 0:56 ` llib at computer dot org
@ 2004-11-29 11:26 ` giovannibajo at libero dot it
2004-11-29 11:41 ` giovannibajo at libero dot it
7 siblings, 0 replies; 9+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-29 11:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-29 11:26 -------
OK, reponening after the thread on comp.std.c++
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/18635] use of uninitialised reference accepted in C++ front end
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
` (6 preceding siblings ...)
2004-11-29 11:26 ` giovannibajo at libero dot it
@ 2004-11-29 11:41 ` giovannibajo at libero dot it
7 siblings, 0 replies; 9+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-29 11:41 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Known to fail| |2.95 3.0.4 3.2.2 4.0.0
Last reconfirmed|0000-00-00 00:00:00 |2004-11-29 11:41:17
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18635
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-11-29 11:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-23 23:11 [Bug c++/18635] New: use of uninitialised reference accepted in C++ front end ajo at acm dot org
2004-11-23 23:19 ` [Bug c++/18635] " pinskia at gcc dot gnu dot org
2004-11-24 2:11 ` llib at computer dot org
2004-11-24 19:07 ` pinskia at gcc dot gnu dot org
2004-11-26 2:56 ` llib at computer dot org
2004-11-26 10:17 ` giovannibajo at libero dot it
2004-11-29 0:56 ` llib at computer dot org
2004-11-29 11:26 ` giovannibajo at libero dot it
2004-11-29 11:41 ` giovannibajo at libero dot it
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).