Topic: Page 59 & page 280


Author: dcb@slsvitt (David Binderman 3841)
Date: Tue, 8 Dec 92 15:39:28 GMT
Raw View
hello there,

Page 59 of the ARM says operator new() with argument 0 gives a non
zero result.

Page 280 of the ARM says operator new() with argument 0 returns 0

Which is right ?

My vote goes for page 59, since I don't want the customers of new
to think that they have run out of memory.

And while I am here, a quick message to all the compiler vendors out there:

have you really checked that your compiler implements page 281 ok ?


Regards

David C Binderman     Dept US/ESI, Bau 60, SEL-Alcatel AG, Lorenz Strasse 10,
D-7000 Stuttgart 40, Germany      dcb@us-es.sel.de   Tel: +49 711 821 3841




Author: hansen@deci.cs.umn.edu (David Hansen)
Date: Wed, 9 Dec 1992 02:50:42 GMT
Raw View
In article <1992Dec8.153928.19016@us-es.sel.de>, dcb@slsvitt (David Binderman 3841) writes:
|> hello there,
|>
|> Page 59 of the ARM says operator new() with argument 0 gives a non
|> zero result.

Furthermore, it says that repeated calls with argument 0 return
pointers to _distinct_ objects.

|>
|> Page 280 of the ARM says operator new() with argument 0 returns 0

My ARM says "If operator new() cannot allocate storage it will return zero."
This is not the same thing.  However, given the restriction that the pointer
returned by operator new(0) be distinct, I suppose there are cases where
it will be unable to allocate the required storage.

|>
|> Which is right ?
|>
|> My vote goes for page 59, since I don't want the customers of new
|> to think that they have run out of memory.

I tend to agree.  I remember reading that there was much discussion in the
ANSI C standard meetings as to whether malloc(0) should return 0 or a
pointer to zero bytes of memory.  If I recall correctly, they never did
settle it, so it became implementation dependant...

|>
|> And while I am here, a quick message to all the compiler vendors out there:
|>
|> have you really checked that your compiler implements page 281 ok ?

Note that the example on p. 281 relies on malloc(0) returning non-zero, which
(in C anyway) in not guaranteed.


     -=Dave




Author: weissman@netcom.com (Bob Weissman)
Date: 9 Dec 92 16:33:40 GMT
Raw View
In article <1992Dec9.025042.15219@news2.cis.umn.edu> hansen@deci.cs.umn.edu (David Hansen) writes:
>In article <1992Dec8.153928.19016@us-es.sel.de>, dcb@slsvitt (David Binderman 3841) writes:
>|>
>|> Page 280 of the ARM says operator new() with argument 0 returns 0
>
>My ARM says "If operator new() cannot allocate storage it will return zero."
>This is not the same thing.  However, given the restriction that the pointer
>returned by operator new(0) be distinct, I suppose there are cases where
>it will be unable to allocate the required storage.

Interesting.  Mine says, "If operator new() cannot allocate storage or if
it is called with the argument 0 it will return 0."

What printing do you have?  I have two different versions (one for the
office and one for home!), both of which contain the sentence as I typed
it.  Both my printings are from 1990.  One of them says "Reprinted with
corrections, December 1990".  The other one lacks this phrase, but I've
never noticed any difference between the two books.

You must have a newer version.  Sigh.  How many of these does a person
need to buy before he gets the "right" one?  Margaret and Bjarne, how
about a low-priced upgrade? :-)  Is there at least an errata list?

--
-- Bob Weissman
-- weissman@netcom.com
--




Author: dcb@slsvitt (David Binderman 3841)
Date: Wed, 9 Dec 92 12:35:42 GMT
Raw View
hansen@deci.cs.umn.edu (David Hansen) writes:
: In article <1992Dec8.153928.19016@us-es.sel.de>, dcb@slsvitt (David Binderman 3841) writes:
: |> Page 59 of the ARM says operator new() with argument 0 gives a non
: |> zero result.
:
: |>
: |> Page 280 of the ARM says operator new() with argument 0 returns 0
:
: My ARM says "If operator new() cannot allocate storage it will return zero."

My ARM is the first or zeroth printing. The bug is corrected in the
second printing. Stroustrup posted 1 Dec 90 with a list of changes that
went into the third printing of the ARM.

I think its time to identify the current ( 9 Dec 1992) printing, and to
encourage a post of the diff between the original ARM version and the
current. Then whatever version of the ARM you have, you get to find out
what has changed.

I think this will benefit us all.

By the way, do later versions of the ARM incorporate changes and
clarifications from the ANSI C++ process ?

Regards

David C Binderman     Dept US/ESI, Bau 60, SEL-Alcatel AG, Lorenz Strasse 10,
D-7000 Stuttgart 40, Germany      dcb@us-es.sel.de   Tel: +49 711 821 3841




Author: mccabe@pogo.den.mmc.com (Steve McCabe)
Date: Thu, 10 Dec 1992 14:21:59 GMT
Raw View
In article <1992Dec9.123542.507@us-es.sel.de>, dcb@slsvitt (David Binderman 3841) writes:
>
> hansen@deci.cs.umn.edu (David Hansen) writes:

> My ARM is the first or zeroth printing. The bug is corrected in the
> second printing. Stroustrup posted 1 Dec 90 with a list of changes that
> went into the third printing of the ARM.
>

     If anybody has the above posting from Stroustrup, I would appreciate it
     if they would email it to me.



                                           Thanks,

                                           Steve McCabe