This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [M68K] avoid compiler warnings from bswap_32 (*p++) usage


Mikael Pettersson <mikpe@it.uu.se> writes:

> Calling bswap_32 on m68k (classic, not ColdFire) with a parameter
> expression that contains a side-effect (like *p++) makes gcc emit
> "operation on <var> may be undefined" warnings.  In my case it broke
> the build of elfutils.
>
> The warnings don't occur on other archs because all other bswap_32
> macros in glibc bind the parameter expression to a local variable,
> which ensures that it is evaluated exactly once.

It's not a problem of multiple evaluation, but rather that GCC is not
smart enough to note that this part of the expression can only be a
constant expression which never has side effects, so the warning is a
false positive.

But there is no reason any more to use macros since nowadays
__builtin_constant_p also works in inline functions, so I have changed
it to that effect.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]