Clang misses left shift count warning found by gcc (original) (raw)

Clang misses a shift count warning found by GCC.

#include <stdio.h> typedef enum shiftof { OFA_FM_POL_ERROR = (1<<32) } shiftof_t;

int main() { printf ("%u %lu %lu\n", OFA_FM_POL_ERROR, sizeof(OFA_FM_POL_ERROR), sizeof(shiftof_t)); }

$ ./bin/clang -Wall shift.c (no warning) $ gcc -Wall shift.c shift.c:3:26: warning: left shift count >= width of type [-Wshift-count-overflow] OFA_FM_POL_ERROR = (1<<32) ^~ $ gcc --version gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10) $ ./bin/clang --version clang version 16.0.0 (https://github.com/llvm/llvm-project 6daa983c9dde7608bcaa20b11e4a7d28fab4e003)