Repository navigation
Conversation
Jamiras
commented
Oct 11, 2026
| dbl = NAN; | ||
| /* An exponent above 127 is a special number: infinity when the mantissa is zero, NaN otherwise. */ | ||
|
|
||
| #if FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 |
Member
Author
There was a problem hiding this comment.
-ffast_math doesn't prevent defining INFINITY or NAN, so we can't detect when it's being applied. Instead, look for the definition of the deconstruction of a float (which also works in c89) and define the constants ourself, avoiding the real constants which would trigger the compiler warning.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An upstream consumer has voiced concerned on compiling with
-ffast-mathgenerating a warning that is then turned into an error by-WerrorThis is because
-ffast-mathassumes the code never will generate or use the NAN and INFINITY float values, and the internal converter knows how to convert MBF32 and DOUBLE32 NaN and infinities.Since we can't prevent the emulated memory from having NaN and infinity values, the best course of action is to still initialize the internal variables with the converted NaN and infinity values and rely on the fact that they're outside the range of all valid floating point numbers so range and equality comparisons will still work.
As best as I can tell, the only behavioral change is comparing NaN always returns false with
-ffast-mathoff, but works like comparing infinity with-ffast-mathon. (i.e.NaN > 3.0is now true, butNaN < 3.0is still false). As long as the achievement logic is checking both upper and lower bounds, or direct equality, there shouldn't be any problems.Note that warning is there for a reason. Using NaN and infinity with
-ffast-mathis undefined behavior. The only reason I even agreed to silence the warning is because of it's interaction with-Werrorand the reasonable assumption that achievement logic isn't reliant on supporting those values.