Possible gcc bug in strict type aliasing
Tue Sep 27 13:09:00 GMT 2016
On 2016-09-26 17:28:38 +0300, Alexander Monakov wrote:
> I concede the original example may invoke UB if the first write to
> malloc'ed region determines its type until free().
No, the effective type is determined by the last write, not the
first one. The C standard says (6.5#6): "[...] the type of the
lvalue becomes the effective type of the object for that access
and for subsequent accesses that do not modify the stored value."
So, the effective type of an object is allowed to change.
Vincent LefÃ¨vre <email@example.com> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the Gcc-help