On 2016.09.27 at 15:08 +0200, Vincent Lefevre wrote: > 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. Both examples are now fixed on trunk by Richi's patch. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77745 -- Markus