3 ms·
Maybe the compiler is telling you all the time what is wrong, see this warning: kernel.h:181:19: warning: operation on ‘sst’ may be undefined [-Wsequence-p
by fhars 5y ago
Maybe the compiler is telling you all the time what is wrong, see this warning:
kernel.h:181:19: warning: operation on ‘sst’ may be undefined [-Wsequence-point]
181 | #define fpop(s) ((--s)->v.f)
| ~^~~~
words.c:2185:27: note: in expansion of macro ‘fpop’
2185 | if ( fpop(sst) <= fpop(sst) )
| ^~~~
For this piece of code:
/**(binary) ge
* "1 1 ge"
* TRUE if TOS-1 is greater than or equal to TOS.
*/
begin(ge)
if ( fpop(sst) <= fpop(sst) )
fpush(sst,TRUE);
else
fpush(sst,FALSE);
end()
That code does assume that the first fpop pops the top of the stack (TOS), and the second one pops the element below that (TOS-1), so "0 1 ge" should return false. But current gcc versions evaluate the calls in the opposite order, so it will return true: https://godbolt.org/z/v4TdvE83b https://godbolt.org/z/v4TdvE83b
Also, you win your nerd sniping badge.