🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

virtual default args problem

#1940
From: Tim Day
Date: Wed, 03 May 1989 20:50
37 lines
1209 bytes
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
Technical Details
Message-ID: <8905032057.AA13021@AENEAS.MIT.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!CS.UCL.AC.UK!T.Day

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!CS.UCL.AC.UK!T.Day
From: T.Day@CS.UCL.AC.UK (Tim Day)
Newsgroups: gnu.g++.bug
Subject: virtual default args problem
Message-ID: <8905032057.AA13021@AENEAS.MIT.EDU>
Date: 3 May 89 20:50:45 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 37