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: Mikael Pettersson <mikpe at it dot uu dot se>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: Mikael Pettersson <mikpe at it dot uu dot se>, libc-ports at sourceware dot org
- Date: Sun, 6 Mar 2011 22:14:34 +0100
- Subject: Re: [M68K] avoid compiler warnings from bswap_32 (*p++) usage
- References: <19827.49418.226302.949940@pilspetsen.it.uu.se> <m2ei6kxcea.fsf@igel.home>
Andreas Schwab writes:
> 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.
Tested, works for me. Thanks.
/Mikael