Topic: Overflow in operator new, was: operator new[](size_t, void*) can be more usefull


Author: James Kanze <james-albert.kanze@vx.cit.alcatel.fr>
Date: 1997/03/03
Raw View
boukanov@hadron.fi.uib.no (Igor Boukanov) writes:

|>  It was pointed out a long time ago in this group that current wording
|>  in 5.3.4.12, 1997 C++ Public Review Draft,
|>  <i>
|>    --new T[5] results in a call of operator new[](sizeof(T)*5+x), and

This has nothing to do with the original poster's question, but ...

What is the status of the program if the expression "sizeof(T)*5+x)"
results in overflow, but "sizeof(T)*5" doesn't?

Note that I can easily check "sizeof(T)*5" before hand, but since the
value of "x" is hidden from me, there is *NO* way that I can check it.
So IF the answer to the first question is "undefined behavior", then it
is impossible to write a conforming program which uses new[].

--
James Kanze      home:     kanze@gabi-soft.fr        +33 (0)1 39 55 85 62
                 office:   kanze@vx.cit.alcatel.fr   +33 (0)1 69 63 14 54
GABI Software, Sarl., 22 rue Jacques-Lemercier, F-78000 Versailles France
     -- Conseils en informatique industrielle --
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]