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
[expr] It is underspecified when evaluating an operation whose operands have values designated NaN #5407
Comments
Yes. C++ is silent on the properties of floating-point operations, and that includes the treatment of infinities or NaN. Those are undefined behavior by virtue of not being expressly defined to anything in particular. C has an Annex that maps floating-point operations to IEEE semantics, including proper NaN treatment. Nobody has proposed something like that for C++, yet. This needs a full-blown paper targeted at EWG, with rationale etc. |
I don't understand it. Since the operations defined for float-point types have defaultly covered |
It's implementation-defined whether any infinity and NaN values exist at all. |
That means, all the operations associated with infinity and NaN should be implementation-defined rather than undefined behavior. However, this point is not clear in the current draft. At least, it can be exposed according to the above comment that we all have different opinions regarding floating-point values. In most subclauses of operations defined in [expr], we merely define rules for arithmetic types without having the special rules for floating-point types. We just have a hazy in floating-point types. Anyway, we have a standard way to acquire infinity and NaN auto infinity = std::numeric_limits<float>::infinity();
auto QNaN = std::numeric_limits<float>::quiet_NaN();
std::cout<< infinity << QNaN ; // #1
|
At best, it's implementation-defined. Note that There is lots of room for improvement here. One avenue (as I already said) would be to actually specify the relationship to IEC 60559 for those platforms whose floating-point is conforming to that. Quoting my earlier comment:
|
Agree. I also don't think we can clarify all of them in an editorial fix. I just want to make this issue be recorded or marked with a CWG tag if possible? Such that we can fix them in the future. |
But it's not a CWG issue. There is no defect here. If you want changes, write a paper for EWG. |
Consider this example
I only list parts of operators that are unclear to NaN, in every subclause that corresponds to the operator or conversion used the above, we do not have a wording that can define what the result is. The only possible relevant wording is in [expr.pre] p4
It is unclear whether
NaN
is mathematically defined. If it were not, it would mean that even the following example also is UBThe text was updated successfully, but these errors were encountered: