<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/157067>157067</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Failure to diagnose inexact narrowing conversion from INT_MAX to float
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mjacobse
</td>
</tr>
</table>
<pre>
In the example
```c++
float a{2147483646};
float b{2147483647};
float c{2147483648};
```
I expected the initialization of `a` and `b` to be rejected and `c`to be accepted, as 2^31 = 2147483648 is the closest integer exactly representable in `float` for all of these. However, clang++ only rejects `a` and accepts `b` and `c`: https://godbolt.org/z/s4ddn8s4c
Contradictingly, it does correctly reject casting `b` back to an `int` in a `constexpr` context as the value is out of range: https://godbolt.org/z/nz64faMo9
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMk09vGyEQxT8Ne0GxWPaf97AHJ-mqOaSnHnqrZmG8JsWwAtZx8umrwZaT5lQJycjP8H7veYAYzewQB9bcs-axgDUdfBiOL6D8FLGYvH4bnhxPB-R4huNikYkda8VlKSbvaYnd3npIHFh3L8u6q7dVW7ese2TVhzh9Frsvovosbm_izYmJ3RPH84Iqoc44xplkwJp3SMY77vectQJYKzg4TfuJ9snzCXnAl8vBq6RYKy4KKIVLQs3kA4fIJWu-VSVn1SP_oOEmZkdlfcSYuHEJZwxUiEr2jQdcAkZ0CSZLXOSQUxHA3gcO1hJfOmDEDf_uX_GEgRyVBTdfOuTe5asINP4T5YIYb5E-ZWDVjh9SWiKrdkyOTI6z15O3aePDzOT4zuQYa63dNtaK6hS7B-9SAG1UMm62b0RhEtceI1c-BLwmIgyuINKvbs4TqD_UKOSIxuWAxnHIPN7FhOcl0JfKu4TnRJVScyewK1KNfk3URAA34__Au_e23sOz7ws9VLqveihwKLumE23XtLI4DF1ZVqqut7LDahIt9LIs27brtd5P2PVdYQYpZCN60ZSi7KXclJ1s5Bb1tgap61KwWuARjN1YezqSd2FiXHEos0thYUIb8wOR0uErzyqTkt5LGOjQ3bTOkdXCmpjixzXJJIvDCMauAak3bWB2PtKM5NnhDkLwr1Sx8u6EIdIk74M_8qcfP38_737RqTxKxRrs8KUtkw7rtFH-yORIptePuyV4-vuYHDNqZHK8ZjkN8m8AAAD___m2OfA">