Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ac_std_float.h:1828:58: warning: operator '?:' has lower precedence than '&' (-Wbitwise-conditional-parentheses) #26

Open
lirp opened this issue Oct 3, 2024 · 0 comments

Comments

@lirp
Copy link

lirp commented Oct 3, 2024

ac_types 4.9.0 changed ac_std_float.h:1828 as follows:

Before:

    d = no_subnormals && f.fpclassify() == FP_SUBNORMAL ? std::signbit(f.d) ? -0.0 : 0.0 : f.d;

After:

    d = no_subnormals & (f.fpclassify() == FP_SUBNORMAL) ? std::signbit(f.d) ? -0.0 : 0.0 : f.d;

It's not obvious to me why short-circuiting wasn't desirable here, however Clang seems to warn on this construction (even though there's no other correct way to interpret the code).

Can some parentheses be added as follows, both to line 1828 and to line 1964?

    d = (no_subnormals & (f.fpclassify() == FP_SUBNORMAL)) ? std::signbit(f.d) ? -0.0 : 0.0 : f.d;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant