tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Compiler bug or violation of strict aliasing rule?

On 2021/11/05 3:48, Christos Zoulas wrote:
In article <>,
Rin Okuyama  <> wrote:
For aarch64eb, GCC 9 and 10 compile this "if" block of

    141          if (sfamily == AF_INET6 && cfamily == AF_INET) {
    142                  ss = bs;
    143                  sin6 = (void *)&ss;
    144                  sin = (void *)&bs;
    145                  addrlen = sizeof(*sin);
    146  #ifdef BSD4_4
    147                  sin->sin_len = sizeof(*sin);
    148  #endif
    149                  sin->sin_family = AF_INET;
    150                  sin->sin_port = sin6->sin6_port;
    151                  sin->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
    152          }

into a code, where fetch for "sin6->sin6_port" is preceding to
structure copy "ss = bs".

This is apparently not what the author of this code intended.

However, I'm not sure whether this is a compiler bug, or a kind of
violation of strict aliasing rule.

Note that the emitted code is "fixed" if (1) -fno-strict-aliasing
option is added, or (2) the attached patch is applied.


I'd apply the patch.

Thanks for your comment! I will commit the patch soon.


Home | Main Index | Thread Index | Old Index