<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98018>98018</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Duplicate diagnostics on use of NAN
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c,
quality-of-implementation,
clang:diagnostics,
floating-point
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
zahiraam
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
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.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVU1v4zYQ_TXjy8CGREqWdNBBcaIiF1-6wCIngxJHFguKdEkq2eSwv72g7HxskHaBFEWBJQTT_Jp5781gRnivjoaohvwKGHsSo3JCTMAY5NcrMYfRuroRzporofUkzKqz8rH-OpJBZXBQRgXCSYRxbY1-xMlKArbDB0Ll_UwYHixKJY7G-qB6j4N1OHtCO-C-2WM3B1weWkNvz2737e3-9ssd8AbHEE4eeAOsBdYereysDhvrjsDaJ2Btdnc3ii9P3ypIriFpLr_b5PKdl4wr0-tZEgLfRbybEfjN2xeH34MIqj8I78kFYOXhNzLkVA-sfIHDdjhoKwJGYGlcShrErM8bCbAq7kX54lcBv_q58X2z_7TddzRPzsq5p0WtD2XgO29n11PkzhsOvGF59PAgnFHmGP9eIqDMEtxHvFcCBU6idxaVx9lIGpQhiR2N4l5ZhzLG2WIYCfvZOTJBPyIZ0WmSZ1rKHNcnq0xAewrKGo-QX62_GmHWz37WUvnlBeTXZ7CIiByh2OF_GhpcRnQD-c2HMmX_INNe7P9fhbKfKvRv8utVnL8bnxXtlxUK8pvv35-rTjt7B6y91B5g7XPpaaoSeJNuo1VjA8WZvp2EkZGos9Mln4AVC6zixU1Vnt0wjnjWb6mkkcqhm5UOyhyMMEPcecXJqg9xvh_nS_w5Zh6PUR0RSG7eFZSVrLmseCVWVKcFS7KMF3m5GutikEVBadJXPE8LymRCfEuMdUMqk7TLV6pmCcuSIilTnjBebvi26rusk0Mi-21VdpAlNAmlN1rfT7HQr5ZeUldlkpYrLTrS_tKw-oXeDhj7cxY6xt4OazWdNE1kYqStebnRa7Fk4Zt29HL2Y2pd2p-rI4B1Nx89ZIlWPvhXSEEFTfX1fNKqF4F-aHLWvOlxq9np-l0PU2Gcu01vJ2BttHiZ1idn_6A-xIyJjD2w9kz6vmZ_BQAA__9XilAJ">