Topic: What standard do you believe?


Author: Max Polk <maxpolk@worldnet.att.net>
Date: 1996/11/13
Raw View
In Marshall Cline's C++ FAQ of November 6, 1996 I downloaded from
comp.lang.c++.moderated, it stated:

     In C++, if the runtime system cannot allocate sizeof(Fred) bytes of
     memory during p = new Fred(), a bad_alloc exception will be thrown.
     Unlike malloc(), new never returns NULL!

However, the April ISO Committee Draft for C++ and the ANSI C++ Draft
located at http://www.cygnus.com/misc/wp/draft/expr.html#expr.new states
concerning "new":

  5.3.4.13
  The allocation function shall either return null or a pointer to a
  block of storage in which the object shall be created.

Marshall Cline's C++ FAQ states emphatically that new never returns zero
yet the April ISO/ANSI C++ draft states that it may.

Would I be right in guessing that the April ISO/ANSI C++ draft is not
considered to be the "cutting edge" of C++ changes, and that Marshall
Cline's C++ FAQ is actually more precise?  If so, can somebody please
explain where I can find the official "cutting edge" of C++ changes?
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl)
Date: 1996/11/13
Raw View
Hi,
Max Polk (maxpolk@worldnet.att.net) wrote:
: In Marshall Cline's C++ FAQ of November 6, 1996 I downloaded from
: comp.lang.c++.moderated, it stated:

:      In C++, if the runtime system cannot allocate sizeof(Fred) bytes of
:      memory during p = new Fred(), a bad_alloc exception will be thrown.
:      Unlike malloc(), new never returns NULL!

: However, the April ISO Committee Draft for C++ and the ANSI C++ Draft
: located at http://www.cygnus.com/misc/wp/draft/expr.html#expr.new states
: concerning "new":

:   5.3.4.13
:   The allocation function shall either return null or a pointer to a
:   block of storage in which the object shall be created.

: Marshall Cline's C++ FAQ states emphatically that new never returns zero
: yet the April ISO/ANSI C++ draft states that it may.

I cannot see the contradiction here... Both are correct. A new
expression shall either return null or a pointer to a block of storage
(if it returns at all).  Note that there are some new expression not
covered by the statement in Marshall's FAQ, e.g. 'Fred *p =
new(nothrow) Fred()': This new expression will return 0 if it cannot
allocate the memory necessary to hold an object of type 'Fred'.

However, I agree that the last sentence is a bit misleading and should
probably be reworded to become something like "Unlike malloc(), the
compiler provided [non-placement] new never returns NULL". Both
conditions, i.e. that the compiler provided new is used and that a
non-placement version of new is used are necessary:  A user can provide
an own version of '::operator new(size_t)' or 'Fred::operator
new(size_t)' not throwing and the standard library provides a placement
version which also does not throw.

: Would I be right in guessing that the April ISO/ANSI C++ draft is not
: considered to be the "cutting edge" of C++ changes, and that Marshall
: Cline's C++ FAQ is actually more precise?  If so, can somebody please
: explain where I can find the official "cutting edge" of C++ changes?

The April ISO/ANSI C++ draft is indeed not the cutting edge but it is
the most cutting one currently available to the public (i.e. to non
committee members). I don't know the outcome of the vote about the next
DWP (currently is a C++ standardization committee meeting) but if they
vote(d) "yes", the next draft is expected to be available toward the
end of this year (the the comp.std.c++ FAQ for a time table of the
standardization process). In any case, I would consider the DWP more
accurate than the FAQ if there are disagreements...
--
<mailto:dietmar.kuehl@uni-konstanz.de>
<http://www.informatik.uni-konstanz.de/~kuehl/>
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: vandevod@cs.rpi.edu (David Vandevoorde)
Date: 1996/11/13
Raw View
>>>>> "MP" == Max Polk <maxpolk@worldnet.att.net> writes:

MP> In Marshall Cline's C++ FAQ of November 6, 1996 I downloaded from
MP> comp.lang.c++.moderated, it stated:

MP>      In C++, if the runtime system cannot allocate sizeof(Fred) bytes of
MP>      memory during p = new Fred(), a bad_alloc exception will be thrown.
MP>      Unlike malloc(), new never returns NULL!

MP> However, the April ISO Committee Draft for C++ and the ANSI C++ Draft
MP> located at http://www.cygnus.com/misc/wp/draft/expr.html#expr.new states
MP> concerning "new":

MP>   5.3.4.13
MP>   The allocation function shall either return null or a pointer to a
MP>   block of storage in which the object shall be created.

This is an oversight, I think (it is still in the pre-Hawaii DWP).
[basic.stc.dynamic.allocation] has the correct wording.

 Daveed
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]