🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

new with placement operator broken in gcc 2.2.1

#898
From: Lewis G. Pringle
Date: Thu, 03 Sep 1992 20:38
22 lines
1150 bytes
// Compiling this file with gcc 2.2.1:
// as follows: g++ -c h.cc
// produces the messages:
//	h.cc: In function `int  f (class ArrayNode)':
//	h.cc:21: parse error before `)'
//
// This simple use of the placement operator new fails. I have found
// no case where it actually works...
typedef unsigned size_t;
static inline void *operator new(size_t, void *place) { return place; }   // from libg++/new.h
class ArrayNode {
	public:
		ArrayNode (int item): fItem (item){}
		~ArrayNode (){}
		int	fItem;
};

int f (ArrayNode n)
{
    ArrayNode* p = (ArrayNode*)new char [sizeof (ArrayNode)];
    new (p) ArrayNode (n);		// Line 21 - WHY DOES THIS FAIL???
}
Technical Details
Message-ID: <m0mQNwH-000AWzC@sophists.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!usc!sdd.hp.com!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sophists.COM!lewis

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!usc!sdd.hp.com!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!sophists.COM!lewis
From: lewis@sophists.COM (Lewis G. Pringle)
Newsgroups: gnu.g++.bug
Subject: new with placement operator broken in gcc 2.2.1
Message-ID: <m0mQNwH-000AWzC@sophists.com>
Date: 3 Sep 92 20:38:00 GMT
Sender: gnulists@ai.mit.edu
Reply-To: lewis@sophists.com
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 22
Approved: bug-g++@prep.ai.mit.edu