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


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


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