Assignment of union containing const-qualifier member

Amol Surati suratiamol@gmail.com
Mon Feb 12 11:18:37 GMT 2024


Typo in the sock_addr section.

Please read
"So typecasting between object types is well-defined, given that the"
as
"So typecasting between pointer types is well-defined, given that the"

> The std says:
> "A pointer to an object type may be converted to a pointer to a different
> object type. If the resulting pointer is not correctly aligned for the
> referenced type, the behavior is undefined. Otherwise, when converted
> back again, the result shall compare equal to the original pointer."
>
> So typecasting between object types is well-defined, given that the
> resulting pointer is indeed correctly aligned for the target type. The
> various sock_addr types all impose a common default alignment,
> because they all begin with a member of the same type.

-Amol


More information about the Gcc-help mailing list