On Wednesday, September 7, 2022, Steffen Nurpmeso <stef...@sdaoden.eu> wrote: > Kang-Che Sung wrote in > <caddzafmeshwlekmsaw3wcltq6fggr813a0qbe1u793_7xbg...@mail.gmail.com>: > |On Wednesday, September 7, 2022, Steffen Nurpmeso <stef...@sdaoden.eu> > |wrote: > ... > |>|> + if(su_64( i > U32_MAX || ) i >= UZ_MAX / 2 || > ... > |>|I have to admit that the amount of macro maze makes it really hard to > |>|read ;) > |> > |> Well it is easier than having lots of #ifdef #else #endif blocks > |> in my opinion. On 32-bit the above would spit out a warning > |> (possibly, i have not really looked what compiler/linker flags > |> busybox uses) because i>U32_MAX can never be true. I mean i could > ... > |Compiler will optimize out always-false expressions without giving any > |warning. > > Regarding the warning: not if you excess an integer limit. > If you say if(0){} i go with you. > Hm. Well, actually it seems current compilers really do so in > simplemost test files at least, like > > int main(void){if(10>0xFFFFFFFFFFFFFFFFULL)return 1;return 0;} > > But already if it is a bit more complicated there is > > int main(void){ > unsigned long long int i = 10; > if(i>0xFFFFFFFFFFFFFFFFULL)return 1; > return 0;} > > t.c:3:6: warning: result of comparison 'unsigned long long' > 18446744073709551615 is always false [-Wtautological-type-limit-compare] > if(i>0xFFFFFFFFFFFFFFFFULL)return 1; > ~^~~~~~~~~~~~~~~~~~~~~~ > 1 warning generated. > > I can assure you that i am surprised, "in earlier times" you would > have been thrown warnings at. (gcc 12.2.0 is silent!!!)
Okay, I didn't notice there is such a warning in Clang, but I would prefer writing this way: if ( (sizeof(i) > 4 && i > U32_MAX) || i >= UZ_MAX / 2 ...
_______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox