[Bug lto/106706] Enabling LTO causes incorrect calculation in in_csum()
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Aug 21 22:52:26 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106706
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is an obvious C/C++ aliasing violation.
ipv4_phdr_t ipv4_phdr;
...
in_csum(({ ( uint16_t *) (&ipv4_phdr); }), sizeof(ipv4_phdr), 0,
&vrrp->ipv4_csum);
inside in_csum:
uint16_t
in_csum(const uint16_t *addr, size_t len, uint32_t csum, uint32_t *acc)
....
while (nleft > 1) {
csum += *addr++;
You need to use either -fno-strict-aliasing or you need to mark the argument
addr in in_csum as may_alias.
More information about the Gcc-bugs
mailing list