| Issue |
74219
|
| Summary |
missing warning on loosing precision to bit fields
|
| Labels |
clang:diagnostics
|
| Assignees |
|
| Reporter |
wheatman
|
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
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs