-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Open
Copy link
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerdiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issue
Description
#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
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerdiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issue