mailing list of musl libc
 help / color / mirror / code / Atom feed
* Operator precedence issue in fma.c.
@ 2015-01-28 14:33 Jukka Jylänki
  2015-01-28 14:58 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Jukka Jylänki @ 2015-01-28 14:33 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

Hi,

building musl fma.c with Clang/LLVM 3.4, I get the following message:

fma.c:276:22: warning: ^ has lower precedence than !=; != will be evaluated
first [-Wparentheses]

                if (bits_lost != 1 ^ (int)(uhi.i & 1)) {

                    ~~~~~~~~~~~~~~~^

fma.c:276:22: note: place parentheses around the '!=' expression to silence
this warning

                if (bits_lost != 1 ^ (int)(uhi.i & 1)) {

                                   ^

                    (             )

fma.c:276:22: note: place parentheses around the ^ expression to evaluate
it first

                if (bits_lost != 1 ^ (int)(uhi.i & 1)) {

                                   ^

                                 (                   )

How does that look to you guys? Is that a real error?

Best Regards,
   Jukka

[-- Attachment #2: Type: text/html, Size: 2503 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Operator precedence issue in fma.c.
  2015-01-28 14:33 Operator precedence issue in fma.c Jukka Jylänki
@ 2015-01-28 14:58 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2015-01-28 14:58 UTC (permalink / raw)
  To: musl

On Wed, Jan 28, 2015 at 04:33:53PM +0200, Jukka Jylänki wrote:
> Hi,
> 
> building musl fma.c with Clang/LLVM 3.4, I get the following message:
> 
> fma.c:276:22: warning: ^ has lower precedence than !=; != will be evaluated
> first [-Wparentheses]
> 
>                 if (bits_lost != 1 ^ (int)(uhi.i & 1)) {
> 
>                     ~~~~~~~~~~~~~~~^

I think the ^ operator here is being used as a logical xor rather than
a bitwise one and the code is working as intended, but since I didn't
write it I'll ask and see. If it is correct, I think removing the
spaces around the != and/or adding parens would make it clearer.

Rich


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-28 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28 14:33 Operator precedence issue in fma.c Jukka Jylänki
2015-01-28 14:58 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).