🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1846

g++ 1.34.1 & uninitialized references

#1846
From: Michael Tiemann
Date: Sat, 08 Apr 1989 06:59
44 lines
2076 bytes
   Date: 28 Mar 89 17:47:34 GMT
   From: rti!xyzzy!bert!coleman@mcnc.org  (Kim Coleman)
   Organization: Data General Corporation, Research Triangle Park, NC.
   Sender: bug-g++-request@prep.ai.mit.edu


   //  Test that the compiler catches uninitialized references. Given that
   //  references are conceptually an object rename, they must be initialized
   //  to something (see Stroustrap, p. 56). At best, g++ gives a warning,
   //  at worst, it says nothing at all.

       void some_function()
       {
	   int&  a_ref;                     // g++ gives a warning
	}
It should give an error here.

       class erroneous {  
	   int&   a_ref;                    // g++ says nothing
       };
This is no cause for alarm.  If you try to use this class without
specifying an initialzer for the reference, they you should get an
error.  But here is how you won't run aground:

int savior;
erroneous not_so_erroneous = { savior };

In this case, savior is specified as an initializer for the reference
in not_so_erroneous.

   Personally, I think both these cases should be an error, but a warning is
   better than nothing. Sorry if this has been posted before.
Error for references are better than warnings, but the compiler should
not be too eager to slap you.

By the way, in working out this example, I found that it does not work
if not_so_erroneous is in global scope.  I have therefore fixed it for
the next release.

   ---------------------------
   Kim Coleman
   Data General Corp., Research Triangle Park, NC
   {the world}!mcnc!rti!dg-rtp!coleman
Technical Details
Message-ID: <8904080659.AA18729@yahi.stanford.edu>
Path: arc1-ca.pugleaf.net!utzoo!telly!lethe!dptcdc!attcan!uunet!tut.cis.ohio-state.edu!YAHI.STANFORD.EDU!tiemann
References: <4609@xyzzy.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!lethe!dptcdc!attcan!uunet!tut.cis.ohio-state.edu!YAHI.STANFORD.EDU!tiemann
From: tiemann@YAHI.STANFORD.EDU (Michael Tiemann)
Newsgroups: gnu.g++.bug
Subject: g++ 1.34.1 & uninitialized references
Message-ID: <8904080659.AA18729@yahi.stanford.edu>
Date: 8 Apr 89 06:59:01 GMT
References: <4609@xyzzy.UUCP>
Sender: news@tut.cis.ohio-state.edu
Reply-To: tiemann@lurch.stanford.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 44