<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/74219>74219</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
missing warning on loosing precision to bit fields
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wheatman
</td>
</tr>
</table>
<pre>
The following code gives warnings about loosing precision when we use an int to initilize a smaller type
```
class A {
int i;
short s;
char c;
A(int x, int y, int z) :
i(x),
s(y), // warning: implicit conversion loses integer precision: 'int' to 'short' [-Wimplicit-int-conversion]
c(z) // warning: implicit conversion loses integer precision: 'int' to 'char' [-Wimplicit-int-conversion]
{}
};
```
However, if that smaller type is a bitfield as in
```
class B {
int i;
int s : 16;
int c : 8;
B(int x, int y, int z) : i(x), s(y), c(z) {}
};
```
no warnings are given
https://godbolt.org/z/7oqY78T58
This issue led to the bug in https://github.com/llvm/llvm-project/issues/71888
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVEGP2jwQ_TXOZQRKJoSYQw6wK_T9gJU-9eg4Q-LK2DTjwLK_vrIBAXvYtmolROJxPPPmvedRzKZ3RI2oNqJ6zdQUBj82p4FU2CuXtb47N28Dwc5b60_G9aB9R9CbIzGc1OiM6xlU66cA1nuOXxxG0oaNd3AayMGJYGIC5cC4AMGDcSYYaz4IFPBeWUsjhPOBRP4q8rVY5tdfWmqrmGENot5cAgCQEhlRPkR48GMAforpQY2gn0JrgTIefhf4krKcby8fAlcgyjXcP06VBMp3gSuBL9cNFijPlwgI3Arc3niIp83-YI02AbR3RxoTC9YzcSxCPY13dlIxrI0LAuvIi8A6tRGXotrM_r8lmxkXZveEonp9BqkFygv-f40nUvincKJS9TUUX278fxL28v-fP9GRxqTCDsKgwpMlwDAoaE3YGbIdqAgbvvDJ5kufxCUnkYvlky3ihk4b8im--bVdHgzyZI27Jr9Hh_MP12m83DD3yNQQwoFFub5o3Puu9TbM_dgL3H4I3Nb-x7davlXy8dDbYBgM80RgqYuihoGgnfrI46eMJgxTO9d-L3Br7fH2mB1G_510ELhNiTjWKqSUVx2yrim7VblSGTVFnRfVciUXVTY0eklY6KqqsFVY5AtZtrWUq7qkoq673S4zDeZYFpiXORY1VvOuq2iRL3GZ7-RS7rRY5LRXxs4jjthqlhA09QKLVWZVS5bT5ELUViXDd0b1znMwmgViHGljk7pop57FIreGA9_zBRMsNXvDaXBdBYB0Rz7PsuCjDyEZkSGbRtv8BYGxg58BAAD__92moaw">