Issue 98018
Summary Duplicate diagnostics on use of NAN
Labels c, quality-of-implementation, clang:diagnostics, floating-point
Assignees zahiraam
Reporter AaronBallman
    When in finite math-only mode, we issue two diagnostics for use of NAN but only one for use of INFINITY: https://godbolt.org/z/4YYhaTzx9

```
#include <math.h>

_Static_assert(_Generic(INFINITY, float : 1, default : 0), "");
_Static_assert(_Generic(NAN, float : 1, default : 0), "");
```
produces:
```
<source>:3:25: warning: use of infinity via a macro is undefined behavior due to the currently enabled floating-point options [-Wnan-infinity-disabled]
    3 | _Static_assert(_Generic(INFINITY, float : 1, default : 0), "");
      | ^
<source>:4:25: warning: use of NaN via a macro is undefined behavior due to the currently enabled floating-point options [-Wnan-infinity-disabled]
    4 | _Static_assert(_Generic(NAN, float : 1, default : 0), "");
      |                         ^
<source>:4:25: warning: use of NaN is undefined behavior due to the currently enabled floating-point options [-Wnan-infinity-disabled]
    4 | _Static_assert(_Generic(NAN, float : 1, default : 0), "");
      | ^~~
/usr/include/math.h:98:16: note: expanded from macro 'NAN'
   98 | #  define NAN (__builtin_nanf (""))
      | ^~~~~~~~~~~~~~~~~~~
3 warnings generated.
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to