[PATCH v4] shell: exchange Dijkstra $(( )) evaluator..
Kang-Che Sung
explorer09 at gmail.com
Tue Sep 6 23:48:03 UTC 2022
On Wednesday, September 7, 2022, Steffen Nurpmeso <steffen at sdaoden.eu>
wrote:
> Kang-Che Sung wrote in
> <CADDzAfMesHwLEkMsaw3WcLTQ6fGgr813A0QBE1U793_7xbgh-Q at mail.gmail.com>:
> |On Wednesday, September 7, 2022, Steffen Nurpmeso <steffen at 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 ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20220907/aeaa56db/attachment.html>
More information about the busybox
mailing list