Discussion:
[Xsb-development] INT_MIN % -1 undefined behavior
Roberto Bagnara
2013-02-08 16:39:35 UTC
Permalink
C expressions like INT_MIN % -1 are undefined behavior in C11
(the 2011 revision of the C standard). This was a pragmatic
decision due to the fact that many compilers (notably, GCC)
did and do miscompile that expression on some popular targets.
It looks like XSB is affected:

$ xsb
[xsb_configuration loaded]
[sysinitrc loaded]

XSB Version 3.3.7 (Pignoletto) of August 12, 2012
[x86_64-unknown-linux-gnu 64 bits; mode: optimal; engine: slg-wam; scheduling: local]
[Patch date: 2012/08/12 15:03:17]

| ?- X is 9223372036854775807, Y is -X -1, Z is Y rem -1.
Floating point exception (core dumped)
--
Prof. Roberto Bagnara

Applied Formal Methods Laboratory - University of Parma, Italy
mailto:***@cs.unipr.it
BUGSENG srl - http://bugseng.com
mailto:***@bugseng.com
Loading...