Article View: gnu.g++.bug
Article #901Re: new int[0]
From: Sebastian Wangnick
Date: Fri, 04 Sep 1992 11:46
Date: Fri, 04 Sep 1992 11:46
25 lines
1477 bytes
1477 bytes
According to basti@orthogo.UUCP: >I just reinstalled gcc-2.2.2 on our RS6000 (configured rs6000-ibm-aix) and >stumbled again over this damn bug within __builtin_new of libgcc2.c: >Allocating e.g., new int[0], fires the new_handler! According to chip@tct.com (Chip Salzenberg): >You're fixing the wrong thing. Instead of allowing malloc() to return >NULL without complaint, you should say "p = malloc (sz ? sz : 1)". Chip, you're wrong. The ARM is quite specific in this case. On page 280 it says: If operator new() cannot allocate storage or if it is called with the argument 0 it will return 0. and: If operator new() cannot find storage to return, it calls a function -- often referred to a the new-handler -- [...]. Calling operator new() with an argument of 0 should thus return 0 WITHOUT calling the new-handler (which is, by the way, also the behavior of all the other C++ compilers). Sebastian Wangnick Orthogon System GmbH (basti@orthogo.uucp) Linzer Strasse 4 Tel +49 421 219136 D-2800 Bremen 33 Fax +49 421 213093 Germany
Technical Details
Message-ID:
<9209040746.AA25409@orthogo.uucp>Path:
arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!orthogo.UUCP!bastiShow 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!orthogo.UUCP!basti From: basti@orthogo.UUCP (Sebastian Wangnick) Subject: Re: new int[0] Message-ID: <9209040746.AA25409@orthogo.uucp> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 4 Sep 1992 11:46:24 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 26