Hello Jim,

Specifically, under gcc with optimization (e.g. -Os), the compiler
determined that `board[sq]' with sq >= 30 would be "undefined
behaviour".  Because of this, it decided to elide out the entire "You
have moved all your pieces off the board" check.  (And unfortunately, it
did not give any warning diagnostic.)  The result was that senet.exe
would never ever declare a winner.

Reference:
https://sourceforge.net/p/simple-senet/code/HEAD/tree/trunk/src/senet.c#l138

That's an interesting bug. Does it still do that if you swap the
comparisons? That would make more sense anyway, because a program
should not check for a value outside the array bounds, and if sq is
not less than 30, then board[sq] is out of bounds.

If I swap the comparisons, the gcc-ia16 compiled program works correctly.

Thank you!

--
https://gitlab.com/tkchia :: https://github.com/tkchia


_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to