Document casting INF/NAN to int is undefined behavior - #121812
Conversation
- Extended warning to document `int(INF)` and `int(NAN)` return `-9223372036854775808` on most platforms
They're meant to be code snippets rather than references to the documentation.
|
Interesting! That would be an improvement for being able to surface the documentation for sure. I could add that if desired, although I do not understand the impact of changing: |
This is just a part of |
|
Is there a way to add an invisible note to the keywords, so if this bug gets fixed in the future, it is clear why these seemingly random int values are in the documentation? |
|
There's no bug here, this is undefined behavior in the C++ language, conversions from floating point values to integers are defined as "If the truncated value cannot fit into the destination type, the behavior is undefined (even when the destination type is unsigned, modulo arithmetic does not apply).", so we'd have to do some arbitrary decision as to what to make it become in those cases |
|
Right, from an implementation standpoint I agree there is no bug, but from a user perspective |
|
I disagree that casting But something to discuss on the issue thread |
|
Regardless of what casting |
|
Could you squash your commits? See our pull request guidelines for more information |

int(INF)andint(NAN)return-9223372036854775808on most platformsWhat problem(s) does this PR solve?
Additional information
While I consider this a bug, it has been present since at least Godot 3.x, so it is better documented until fixed.