🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Two bugs within gcc-2.2.2

#819
From: Mike Stump
Date: Sat, 29 Aug 1992 14:05
46 lines
1686 bytes
This is wrong.  This patch will never make it into the gcc distribution.

ANSI C++ June 5, 1992 working paper states: ``When the value of the
first array dimension is zero an array with no elements is allocated.
The pointer returned by the new-expression will be non-null and
distinct from the pointer to any other object.''

Do you understand why the below would be wrong?

Maybe code like:

  if (sz == 0)
    ++sz;
  p = (void *) malloc (sz);

will fix your problem.  Let me know.

> From: Sebastian Wangnick <orthogo!basti@ai.mit.edu>
> Date: Thu, 27 Aug 92 16:21:17 +0200
> Message-Id: <9208271421.AA07068@orthogo.uucp>
> To: bug-gcc@prep.ai.mit.edu
> Cc: basti@germany.eu.net

> 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! I patched this with:

> *** libgcc2.c  Thu Aug 27 15:46:30 1992
> --- /tmp/lc Thu Aug 27 15:54:20 1992
> ***************
> *** 969,975 ****
>   {
>     void *p;
>     p = malloc (sz);
> !   if (p == 0 && sz)
>       (*__new_handler) ();
>     return p;
>   }
> --- 969,975 ----
>   {
>     void *p;
>     p = malloc (sz);
> !   if (p == 0)
>       (*__new_handler) ();
>     return p;
>   }
Technical Details
Message-ID: <9208291405.AA28967@cygnus.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cygnus.com!mrs

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cygnus.com!mrs
From: mrs@cygnus.com (Mike Stump)
Subject: Re:  Two bugs within gcc-2.2.2
Message-ID: <9208291405.AA28967@cygnus.com>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Sat, 29 Aug 1992 14:05:43 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 47