andru@proton.lcs.mit.edu (Andrew Myers) (10/03/90)
The gnu C++ compiler doesn't like the following program, yet so far as I recall, it works fine on C++2.0 from AT&T. Anyone know what's going wrong? It reports "parse error just before malloc" on the line with the second call to new. Seemingly, g++ doesn't support additional arguments to new. -- Andrew #include "new.h" extern "C" void *malloc(size_t); class A { public: void *operator new(size_t s) { return malloc(s); } void *operator new(size_t s, void *x) { return x; } int b; }; main() { A* a = new A; A* a2 = new(malloc(sizeof(A))) A; }
pillera@etd4260a.erim.org (Joe Pillera) (10/03/90)
Forgive me for my ignorance [ :-) ], but what's g++?? -joe -- ----- Joe Pillera ERIM Research Scientist Image Processing Systems Division pillera@etd4260a.erim.org P.O. Box 8618 (313) 994-1200 x2754 Ann Arbor, Michigan 48107-8618 Disclaimer: The opinions expressed here are solely those of Joe Pillera, and not of ERIM or its affiliates.
levericw@clutx.clarkson.edu (Druid Allanon,Integrator,2659050,2652545) (10/04/90)
From article <PILLERA.90Oct3082245@etd4260a.erim.org>, by pillera@etd4260a.erim.org (Joe Pillera): > Forgive me for my ignorance [ :-) ], but what's g++?? > > -joe > -- > g++ if the GNU projects C++ compiler. -Walden --------------------------------------------------------------------------- Walden H. Leverich III | Inet: levericw@clutx.clarkson.edu ECE Dept. | CServ: 73237,2212 <- checked weekly Clarkson University | SnailMail: 100 Market St. | N.C.M. Apt 18 | Potsdam, NY 13676-1703 #include <std_disclamer_about_what_I_say> --------------------------------------------------------------------------
joseph@cs.albany.edu (Jody Richardson) (10/05/90)
> second call to new. Seemingly, g++ doesn't support additional arguments > to new. -- Andrew I'll take a stab at this and say that your supposition is correct. According to Lippman in his book _C++ Primer_ from Addison-Wesley (p. 256 top), "The predefined arity of the operator must be preserved. The unary logical NOT operator ("!"), for example, cannot be defined as the binary inequality operator for two String Class objects." -- Jody Richardson joseph@cs.albany.edu
ericg@ucschu.ucsc.edu (Eric Goodman) (10/09/90)
In article <1990Oct2.215020.23361@mintaka.lcs.mit.edu> andru@proton.lcs.mit.edu (Andrew Myers) writes: > The gnu C++ compiler doesn't like the following program, yet so far as > I recall, it works fine on C++2.0 from AT&T. Anyone know what's going I believe new() overloading is illegal in versions prior to 2.0. Is your G++ 2.0 or 1.35? That may be the problem. Eric Goodman, UC Santa Cruz ericg@ucschu.ucsc.edu ericg@ucschu.bitnet