On 6/30/23 15:13, Dan Carpenter wrote:
So here we have: if (u32_val > SOMETHING) { The condition is impossible when the code is compiled on a 64-bit system
This is exactly what the compilers warns about: $ cat test.c #include <stdint.h> int f (int *p, unsigned n) { return n > SIZE_MAX / sizeof (*p); } $ gcc -Wextra -c test.c test.c: In function ‘f’: test.c:5:12: warning: comparison is always false due to limited range of data type [-Wtype-limits] 5 | return n > SIZE_MAX / sizeof (*p); | ^ $ gcc -m32 -Wextra -c test.c $ clang -Wextra -c test.c test.c:5:12: warning: result of comparison of constant 4611686018427387903 with expression of type 'unsigned int' is always false [-Wtautological-constant-out-of-range-compare] return n > SIZE_MAX / sizeof (*p); ~ ^ ~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. $ clang -m32 -Wextra -c test.c $ Where is a bug here? What the compiler developers are intended to fix? How the compilers should behave in this case? Dmitry