C++ Logo

sg12

Advanced search

Re: [ub] type punning through congruent base class?

From: Tony Van Eerd <tvaneerd_at_[hidden]>
Date: Fri, 17 Jan 2014 18:05:36 +0000
>
> Going back to constructor, what C++ has done is to automatically
> "bless" or perform the conceptial equivalent of access that stamps the
> effective type of the object. That also highlights why C++ is
> carefully in what can be done between the timeframe where storage is obtained and
> initialization is complete (e.g. the effective type/dynamic type is
> stamped.)
>

I think that is the way forward. After the constructor, the memory has been blessed/stamped/whatever.

The "object" returned from malloc is a "sequence of N unsigned char objects" (purposely quoting from 3.9's definition of 'object representation'). ie ready to be an object of whatever type, but not yet blessed beyond the base type unsigned char. (You could try to say it isn't even an array of unsigned char, but I don't think that will help.)

You then need to go at least some distance down the road of C's "effective type".

Tony
---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

Received on 2014-01-17 21:13:06