[clang] [clang][C23] Allow NaN in constant evaluation (PR #167892)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 9 11:17:11 PST 2025
================
@@ -222,6 +222,8 @@ C23 Feature Support
the same translation unit but from different types.
- ``-MG`` now silences the "file not found" errors with ``#embed`` when
scanning for dependencies and encountering an unknown file. #GH165632
+- Allow NaN in constant expression evaluation to maintain consistency with
----------------
AaronBallman wrote:
> I get the frustration that this seems like a senseless restriction but I am not seeing the utility.
There's two things here.
The original thing is ensuring we can do the static initialization *in C*. This was an initialization that previously worked and we broke in Clang 19: https://godbolt.org/z/P44zaob6Y This needs to be fixed because it's clearly a Clang bug.
The other thing is that this patch goes a bit further and tries to make constant expression evaluation work. I think we should split that off into a separate patch so that we can debate it when there's less pressure of a pending branch after the holidays.
But the utility here is pretty simple: WG21 should not prohibit an implementation from following IEEE floating-point semantics without some serious justification because it's disruptive in practice. qNaN and sNaN are different tools which serve different purposes and treating them as being the same thing in a constant expression takes actual utility out of users hands and forces the overhead of doing it at runtime. Where's the utility in that?
https://github.com/llvm/llvm-project/pull/167892
More information about the cfe-commits
mailing list