[gnu.g++.bug] virtual default args problem

T.Day@CS.UCL.AC.UK (Tim Day) (05/04/89)

The below example gives a 'Program c++ got fatal signal 6.' under
g++ version 1.34.2.
---------
#include <String.h>

	String blurb("bleah");

class Foo
{	String a;
public:
	Foo()	{}
	virtual void scooby(String s=blurb)			{a=s;}
	virtual void doobie(String s=String("bleaurgh"))	{a=s;}
};

class Bar : public Foo
{	String b;
public:
	Bar()	{}
	virtual void scooby(String s=blurb)			{b=s;}
	virtual void doobie(String s=String("bleaurgh"))	{b=s;}
		// Above line causes problem
};	

main()
{	Foo x;
	Bar y;

	exit(0);
}
----------
Commenting out the 'doobie' member function of 'Bar' eliminates this.
I'm not sure if this sort of default arg. should be allowed anyway since
the two 'String("bleaurgh")'s are effectively different things, but obviously
an error message of some sort is preferable

Tim

gordon%stats.ucl.ac.uk@NSFNET-RELAY.AC.UK (Gordon Joly) (05/05/89)

Tim,
Is this fixed in 1.35.0- ?
Gordon.

karl:/stats/staff/karl/gordon/c++[60] make scoobie
g++ -g  -lg++ -lm  scoobie.cc   -o scoobie
scoobie.cc:13: sorry, not implemented: that operation not supported for default parameters
g++: Program c++ got fatal signal 6.
make: *** Error 1
karl:/stats/staff/karl/gordon/c++[61] g++ -v
g++ version 1.35.0-
karl:/stats/staff/karl/gordon/c++[62] date
Fri May  5 13:44:03 BST 1989
karl:/stats/staff/karl/gordon/c++[63] cat -n scoobie.cc
     1	//The below example gives a 'Program c++ got fatal signal 6.' under
     2	// g++ version 1.34.2.
     3	// ---------
     4	#include <String.h>
     5	
     6		String blurb("bleah");
     7	
     8	class Foo
     9	{	String a;
    10	public:
    11		Foo()	{}
    12		virtual void scooby(String s=blurb)			{a=s;}
    13		virtual void doobie(String s=String("bleaurgh"))	{a=s;}
    14	};
    15	
    16	class Bar : public Foo
    17	{	String b;
    18	public:
    19		Bar()	{}
    20		virtual void scooby(String s=blurb)			{b=s;}
    21		virtual void doobie(String s=String("bleaurgh"))	{b=s;}
    22			// Above line causes problem
    23	};	
    24	
    25	main()
    26	{	Foo x;
    27		Bar y;
    28	
    29		exit(0);
    30	}
    31	// ----------
    32	// Commenting out the 'doobie' member function of 'Bar' eliminates this.
    33	// I'm not sure if this sort of default arg. should be allowed anyway since
    34	// the two 'String("bleaurgh")'s are effectively different things, but obviously
    35	// an error message of some sort is preferable
    36	// 
    37	// Tim
    38	
karl:/stats/staff/karl/gordon/c++[64] 

T.Day@CS.UCL.AC.UK (Tim Day) (05/05/89)

But you do get an error message now ("sorry, not implemented:"...etx),
whereas 1.34.2 just dies.

I didn't realise we had 1.35.0.. On Karl 'which g++' now gives
the span copy... will have to fiddle with my $path.