<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64555>64555</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Inaccurate warning for direct-initialization of `bool` to `nullptr`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eisenwave
</td>
</tr>
</table>
<pre>
Given the following code (https://godbolt.org/z/YrEnGb35W):
```cpp
bool b(nullptr);
```
clang emits the warning:
```
<source>:1:8: warning: implicit conversion of nullptr constant to 'bool' [-Wnull-conversion]
bool b(nullptr);
~ ^~~~~~~
false
```
However, no conversion should take place here; instead, this is a special case:
> Otherwise, if the initialization is *direct-initialization*, the source type is `std::nullptr_t`, and the destination type is `bool`, the initial value of the object being initialized is `false`.
\- [[dcl.init.general] p16.8](https://eel.is/c++draft/dcl.init.general-16.8)
## Suggested Fix
The warning should instead state:
```
direct-initialization of bool to nullptr
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE2P2zYQ_TWjy8ACTa5k6aCDvWulPfXQAkFPBUWNJbY0KZCU3eSQ315Q8saOmyCCYYGj-XzvcWQIerBEDRQHKN4yOcfR-eaoA9mrvFDWuf5T80FfyGIcCU_OGHfVdkDlekLg1RjjFEDsgbfA28H1nTMxd34A3n4G3v7pj_ZDJ4qPwOvkxt6A7aFk609N02rpnDPYAa_sbMwU_eJ9ePJej8pIOyCddQxLT1fprbbD_5PfjuI1uNkrAnEEsd-C2Fcg9g9hqM-T0UpHVM5eyAftLLoT3lpJ1hCljRgdAt-lVoHvEIrD5mPy2dzDoHj7-TyYni8IxfHL8jxYEU_SBPr-IMv_L-5KF_LAX9G6x4bD6GbTY5T_EE5GKsKRPIE4oLYhkuxTSBx1QB1QYphIaWlQyUB36MQRf4sj-asOlPz1aYFYWx21NPqzjKmUDgh832tPKm6-_QZ8v9YhXFHH-GmiJaJkIfZw5FAxqA6ppth_Pd5g-iumcfkrStsvSXoKUdu17EOmhYPV86E_vEgzU6IuGV33N6mIHSW5fu2S-luKFeiS5Y_oQvG6weUuHHpl8hSVD2TJSwPFG07bMq8Sx8-6JzK5DsBbBfwA_NB7eYrA2-ckmyUBr7-pyQVwgb_Pw0AhUo-t_nf98sdd3e_03rjEEGWkH0n-u8wkWBZVRveu7KfgrG9EX4taZtRsy3pb7Goh6mxsmCgr6jtRnGqmFCdGkl5Kqjq2Y6LoVKYbzrhgFau3W1YVVU6K9_WOF6x-YTvqtvDC6Cy1yY25nNN2yHQIMzXlS1EUmZEdmfC-g3yTnDbdPAR4YUaHGO5hUUezbKtlCyROfrVSqdnLeMfq5Dz-EIO7epb7XLJ3MEqWzd40TwtNx3HucuXOwNvUxe21mbxL8gLeLpMk7pdh_gsAAP__JjGmLw">