[tz] Minor (unimportant really) technical UB bug in strftime() ?

Clive D.W. Feather clive at davros.org
Wed Nov 9 23:07:06 UTC 2022

John Marvin via tz said:
> I'm not sure what the standard says about struct copies,

Footnote 42:

    42)Thus, for example, structure assignment may be
    implemented element-at-a-time or via memcpy.

This is in the context of:

    When  a  value  is stored in an object of structure or
    union type, including in a member object, the bytes  of  the
    object  representation  that correspond to any padding bytes
    take  unspecified  values.42)   The  values of padding bytes
    shall not affect whether the value of such an  object  is  a
    trap  representation.

So if all the members of a structure hold object representations that
aren't trap representation, then structure copy is valid no matter how
implemented, though any padding bytes can change value unpredictably.

Clive D.W. Feather          | If you lie to the compiler,
Email: clive at davros.org     | it will get its revenge.
Web: http://www.davros.org  |   - Henry Spencer
Mobile: +44 7973 377646

More information about the tz mailing list