🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Kim Coleman Tue, 28 Mar 1989 17:47
g++ 1.34.1 & uninitialized references
#1805
Author: Kim Coleman
Date: Tue, 28 Mar 1989 17:47
22 lines
1222 bytes
//  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
     }

    class erroneous {  
        int&   a_ref;                    // g++ says nothing
    };

Personally, I think both these cases should be an error, but a warning is
better than nothing. Sorry if this has been posted before.

---------------------------
Kim Coleman
Data General Corp., Research Triangle Park, NC
{the world}!mcnc!rti!dg-rtp!coleman
g++ 1.34.1 & uninitialized references
#1846
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads