🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Ron Guilmette Fri, 10 Mar 1989 22:18
BUG(s) in G++ 1.34.0 - missing errors
#1720
Author: Ron Guilmette
Date: Fri, 10 Mar 1989 22:18
70 lines
3005 bytes
I'm not sure what the precise rules are regarding the required visibility
of constructors at points where they are invoked, but the following code
indicates that G++ (1.34.0/Sun3) does *not* issue errors at those points
where a given constructor is called even though it is "private" (and therefore
invisible?) at these points.

I believe that all of the lines marked with // ERROR in the code below should
be flagged by the compiler as containing errors.  The basis of this belief
comes from Stroustrup's article in the 1987 SantaFe proceedings (page 11)
where he notes that you can effectively make a given operation (i.e. assignment)
illegal (for objects of the class, in areas outside of the class) simply by
explicitly declaring the given operation within the private part of the class
declaration.  If this is also true for the "construction" operation, then
g++ should be issuing errors for all the // ERROR lines below.

Following the code is the compilation log.  Note that no errors or warnings are
issued.

Cut here.
-------------------------------------------------------------------------------
/*
Description - check that if a default constructor is needed (e.g. at the point
		where an object is created) and that if there is a constructor
		which takes zero arguments but which is private, a reasonable
		error message is issued.

		Cases: objects which are: (1) static (2) auto (3) heap.

		Cases: objects of (1) a type which has a private default
		    constructor, and (2) objects of a type derived from a type
		    which has a private default constructor.
*/

class base
{
    base();
    friend class friendly;
};

static base static_base_object_1;		// ERROR
base static_base_object_2;			// ERROR

void f1 ()
{
	base local_base_object;			// ERROR
	base *base_ptr = new base;		// ERROR
}
 
class derived : base
{
public:
    derived();
};

static derived static_derived_object_1;		// ERROR
derived static_derived_object_2;		// ERROR

void f2()
{
	derived local_derived_object;		// ERROR
	derived *derived_ptr = new derived;	// ERROR
}
----------------------------------------------------------------------------------
g++  -S -v x02.cc
g++ version 1.34.0.0
 /usr/local/src/lib/1.34.0.0/sun3/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 x02.cc /tmp/cca07700.cpp
GNU CPP version 1.34.0.0
 /usr/local/src/lib/1.34.0.0/sun3/gcc-c++ /tmp/cca07700.cpp -quiet -dumpbase x02.cc -noreg -version -o x02.s
GNU C++ version 1.34.0.0 (68k, MIT syntax) compiled by GNU C version 1.33.
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