Topic: initialization of arrays


Author: jamshid@ses.com (Jamshid Afshar)
Date: Tue, 15 Feb 1994 17:55:44 GMT
Raw View
Redirected to comp.std.c++.

In article <9404504.26016@mulga.cs.mu.oz.au>,
Fergus Henderson <fjh@munta.cs.mu.OZ.AU> wrote:
>jamshid@ses.com (Jamshid Afshar) writes:
>>Actually, I think you can prove that `new char[...]' must return a
>>block of memory properly aligned to store an A.  ANSI C requires
>>malloc() to return a block of memory that is properly aligned for any
>>object of the requested size or smaller.  [...]
>
>But how do you know that the compiler and the standard library
>operator new() aren't cooperating to convey additional information
>(such as the exact type requested) via global variables?

The "Result semantics" of WP 17.1.1 Free Store requires that "The
pointer returned is suitably so that it may be assigned to a pointer
of any type and then be used to initialize [...] an object or an array
of such objects [...]."  The WP also says "Any C++ program that
replaces any of [the allocation functions] with functions having
different result semantics causes that program to have undefined
behavior."

Jamshid Afshar
jamshid@ses.com