C++ Logo


Advanced search

Subject: Re: [ub] type punning through congruent base class?
From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2014-01-16 16:14:01

| >>> Agreed. I would expect line 4 to be at least unspecified behavior and
| >>> probably undefined behavior.
| >
| > OK, let me back this off to just "I would expect that in this code no lifetime
| of any object has begun."
| So, a subsequent read of "pb->x" would then be undefined behavior
| according to 3.8p5 bullet 2?

In the C world, the storage at "&pb->x" has effective type "int".

| This seems to break C compatibility, since the code above (after replacing
| the static_cast) certainly works as expected in C.
| I have no objections to someone rewriting 3.8 basic.life to suit feelings
| about the intuitive meaning of "lifetime", but let's please have a holistic
| approach in a paper.

SG12 list run by sg12-owner@lists.isocpp.org