<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/92656>92656</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
No warning generated for implicit narrowing conversion during constant evaluation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
katzdm
</td>
</tr>
</table>
<pre>
The fixes for C++23 [P2564](https://wg21.link/p2564) merged by #89565 expanded the class of constant evaluated variable initializers. This inadvertently resulted in some warnings no longer diagnosing, e.g.,
```cpp
constexpr char h = u'\u5678'; // previously diagnosed warn_impcast_integer_precision_constant
```
A suggested approach is to mark both diagnoses of `warn_impcast_integer_precision_constant` as `DiagRuntimeBehavior` (which was previously the case), and to separately diagnose in the constant evaluator. This could be done by deducing narrowing during evaluation, or by marking narrowing expressions during semantic analysis and thereafter diagnosing if any such expressions are evaluated. Ideally, the above would diagnose, but an initializer like the following would not:
```cpp
constexpr char h = (true ? 'a' : u'\u5678');
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVMGO4zYM_RrlQmzgyLETH3yYTBCgl6Io9j6gJcZmR5YMUU42-_WFnEk3M720QBAJFp_4HvlEFOHeE7WqOqjquMI5DSG275h-2nHVBXtrvw8EZ_5BAucQ4VXpg9IHXYKqDn_oqt6q6qj0fkhpElW-KH1S-nTt9Wbt2L8rfZqWIN3ASLEnC90NlC73TVVXQD8m9JYspIHAOBSBcAYTvCT0CeiCbsZEFi4YGTtHwJ4To-OfFGUN3wcWYI_2QjGRT-4GkWR2GcIeJIwEV4yefS_gA7jge4pgGXsfhH2v9CvQul8r_aqKoypePv7r4v4z03T_snCiH1MEM2CEAVR5hFnpnape56re7fO2PADcCwBTpAuHWdztkY3sQuWNx8mgpDf2iXqKb1Mkw8LBvz10f-HwTOwFZO57kiwQpykGNAOwQAowYnyHLqThn4RLMVVd_Ne0dQEoGXBk7P-cfeKRDjTghUPMh0rvrwObAa4ozwKX5qGQ0k2uJ3qb-QhNGDHRUwVyT5bgLw0O8aOVJszOQkdgg6fsFEt2Nux78BhjuOadnWNePqAcfM4ZYo7OJfgcnDtGkmXKAyg0ok9sAD26m7DcCQ8UCc_pkzuAz4D-BjKb4dNVGOmXOdfwmyV07paJZHnYhQvBddHykJ7PujkB-mcLg-N3WjDn4Nyd8h3nQ8qv6f97Uul9ijOBKk-g9A6V3oEqX_7lVd2o8vDl5pVtS9uUDa6o3ew2dbHdbXW1Gtrdpu42hSnMtqOzsdTsdWOtrRvcayx1seJWF3pbVJv9pqoKXa319tw1BZYWd_UO67PaFjQiu7Vzl3EdYr9ikZnaRtdVvXLYkZNlCGnt6QrLodI6z6TYZsy3bu5FbQvHkuTXLYmTo_b38Hjm0JOnuMyMPK54nBwbTk-WMMFfKOY-Phzx1Y4c_GqOrv0803pOw9ytTRiVPuX8H8u3KYa_yCSlTwtrUfq0qPo7AAD__0Zfyi8">