public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-18635-9680@http.gcc.gnu.org/bugzilla/>]
* [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; 24+ 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] 24+ messages in thread

end of thread, other threads:[~2024-04-12  0:06 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-18635-4@http.gcc.gnu.org/bugzilla/>
2010-11-26  1:05 ` [Bug c++/18635] use of uninitialised reference accepted in C++ front end adam.rak at streamnovation dot com
2010-11-26 11:23 ` redi at gcc dot gnu.org
2010-11-26 11:29 ` manu at gcc dot gnu.org
2010-11-26 12:00 ` redi at gcc dot gnu.org
2010-11-26 17:28 ` pentek.imre at gmail dot com
2010-11-26 18:40 ` redi at gcc dot gnu.org
2010-11-27 14:53 ` adam.rak at streamnovation dot com
2011-05-22 19:11 ` redi at gcc dot gnu.org
2011-06-27 11:55 ` [Bug c++/18635] [DR 504] " redi at gcc dot gnu.org
2021-04-08  0:20 ` [Bug c++/18635] [DR 504] use of uninitialised reference accepted (without -Wuninitialized) " msebor at gcc dot gnu.org
2021-04-08  8:16 ` manu at gcc dot gnu.org
2021-04-08 14:24 ` msebor at gcc dot gnu.org
2021-08-10 19:46 ` redi at gcc dot gnu.org
2024-04-12  0:06 ` mpolacek at gcc dot gnu.org
     [not found] <bug-18635-9680@http.gcc.gnu.org/bugzilla/>
2005-11-27 21:18 ` [Bug c++/18635] use of uninitialised reference accepted " gdr at gcc dot gnu dot org
2009-05-29 14:36 ` pinskia at gcc dot gnu dot org
2004-11-23 23:11 [Bug c++/18635] New: " 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).