This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
Re: [M68K] avoid compiler warnings from bswap_32 (*p++) usage
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: Mikael Pettersson <mikpe at it dot uu dot se>
- Cc: libc-ports at sourceware dot org
- Date: Sun, 06 Mar 2011 20:43:57 +0100
- Subject: Re: [M68K] avoid compiler warnings from bswap_32 (*p++) usage
- References: <19827.49418.226302.949940@pilspetsen.it.uu.se>
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."