Issue 149288
Summary [clang] False-positive warning for integer promotion [-Wimplicit-int-conversion]
Labels clang
Assignees
Reporter Mephistophiles
    ```c
#include <stdint.h>

_Static_assert(__builtin_types_compatible_p(typeof(UINT8_C(1)), int), "");
_Static_assert(__builtin_types_compatible_p(typeof(UINT8_C(1)), uint8_t) == 0, "");

int foo(uint8_t b)
{
    uint8_t a = ((uint8_t)1) << b;
    return __builtin_types_compatible_p(typeof(((uint8_t)1) << b), int);
}

```
https://godbolt.org/z/s1f64449b

Code snippet gives a warning:
```
<source>:8:30: warning: implicit conversion loses integer precision: 'int' to 'uint8_t' (aka 'unsigned char') [-Wimplicit-int-conversion]
    8 |     uint8_t a = ((uint8_t)1) << b;
 |             ~   ~~~~~~~~~~~~~^~~~
```

However, this behavior is not considered an error in gcc (there is no warning):
https://godbolt.org/z/d1KjrbKdd
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to