🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Bug in overloading new?

#1025
From: David J Dawkins
Date: Mon, 05 Oct 1992 11:39
72 lines
2506 bytes
G++2.2.2 does not seem to be able to handle overloading of the new operator
where arrays are concerned.

I am not sure whether this is a 
  - bug,
  - 'sorry, not implemented' or
  - misunderstanding on my part

Example :

------------------------------------->8------------------------------
#include "stdlib.h"

class Segment;

void *
operator new( size_t sz, Segment * )
{
	return malloc(sz);
}

main()
{
	Segment *s = 0;

	char *c = new {s} char;
	char *b = new {s} char[4];
}
------------------------------------->8------------------------------

Compilation gives:

valhalla% g++ c.c  
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/specs
gcc version 2.2.2
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix c.c /usr/tmp/cca16258.i
GNU CPP version 2.2.2 (sparc)
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cc1plus /usr/tmp/cca16258.i -quiet -dumpbase c.cc -version -o /usr/tmp/cca16258.s
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
c.c: In function `int  main ()':
c.c:16: placement syntax invalid for arrays

valhalla% uname -a
SunOS valhalla 4.1.1 1 sun4c

Do I have the syntax wrong? (This compiles OK under cfront3.0.1, but with
round brackets instead of braces). 

[ If I have the syntax wrong, this is because I have no docs later than 
October 19th 1991 (for version 1.40.3). Can someone _please_ let me know
where more up-to-date docs are. ]

I looked up the relevant code in cp-init.c 

    File: "cp-init.c" [Read only] line 2947 of 4019 --73%-- 
Function: tree build_tree( tree, tree, tree, int)

  if (has_array) 
    {
      if (placement)
        {
          error ("placement syntax invalid for arrays");
          return error_mark_node;
        }

It looks like it should be a 'sorry, not implemented'. What gives?

Dave Dawkins
--
djd@csg.cs.rdg.ac.uk
djd@csug.cs.rdg.ac.uk
davidd@integ.uucp
Technical Details
Message-ID: <9210051139.AA16351@csg.cs.reading.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!uk.ac.reading.CS.CSg!djd

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!uk.ac.reading.CS.CSg!djd
From: djd@uk.ac.reading.CS.CSg (David J Dawkins)
Subject: Bug in overloading new?
Message-ID: <9210051139.AA16351@csg.cs.reading.ac.uk>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 5 Oct 1992 11:39:49 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 75