[LTP] [PATCH v1] syscalls/signal06: add volatile to loop variable
Cyril Hrubis
chrubis@suse.cz
Tue Jul 19 12:20:37 CEST 2022
Hi!
> On Android compiled with clang, the loop variable will be optimized out
> unless it is tagged with volatile.
Looking at the code it looks strange that it's optimized out since we
use the value for the loop as:
loop = 0;
D = VALUE;
while (D == VALUE && loop < LOOPS) {
asm(...);
loop++;
}
And the D variable is properly marked as volatile so it's not like the
loop can be expected to iterate preciselly LOOPS iterations.
It looks to me like the compiler actually forgets about the volatility
of D for some reason and then assumes that the loop does LOOPS
iterations.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list