Hi, on 2021/1/4 上午2:53, William Roberts via Gcc-help wrote: > When I compile the below program, I expect the -Wtype-limits warning > to be displayed for all 4 if conditions, but I only get uint8_t and > uint16_t conditions, why? This is a known issue, see below PR. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89126 BR, Kewen > > #include <stdint.h> > #include <stdlib.h> > > int main(int argc, char *argv[]) { > (void)argv; > > uint8_t i8 = (uint8_t) argc; > uint16_t i16 = (uint16_t) argc; > uint32_t i32 = (uint32_t) argc; > uint64_t i64 = (uint64_t) argc; > > if (i8 > UINT8_MAX) { > return 8; > } > if (i16 > UINT16_MAX) { > return 16; > } > if (i32 > UINT32_MAX) { > return 32; > } > if (i64 > UINT64_MAX) { > return 64; > } > > return 0; > } > > gcc -Wall -Wextra -o go a.c > a.c: In function ‘main’: > a.c:13:9: warning: comparison is always false due to limited range of > data type [-Wtype-limits] > 13 | if (i8 > UINT8_MAX) { > | ^ > a.c:17:10: warning: comparison is always false due to limited range of > data type [-Wtype-limits] > 17 | if (i16 > UINT16_MAX) { > > gcc --version > gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 > Copyright (C) 2019 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > Thanks, > Bill >