[ub] type punning through congruent base class?

Gabriel Dos Reis gdr at microsoft.com
Thu Jan 16 23:14:01 CET 2014


| >>> 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.



More information about the ub mailing list