vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
1.13k stars 135 forks source link

Corrupted characters in {-9223372036854775808} #219

Closed tueda closed 7 years ago

tueda commented 7 years ago

The preprocessor calculator prints the minimum negative number wrongly.

* for 64-bits version
#message {-9223372036854775808}
.end
FORM 4.2.0 (Jul 11 2017, v4.2.0-8-ga8b9963) 64-bits  Run: Wed Jul 12 14:22:11 2017

~~~-(

Presumably for the same reason as in #139.

tueda commented 7 years ago

Failed with clang?? https://travis-ci.org/tueda/form/builds/253705758 (See Issue219.)

vermaseren commented 7 years ago

I am not quite sure what you mean with this. On the apple my fix worked.

Jos

On 15 jul. 2017, at 19:28, Takahiro Ueda notifications@github.com wrote:

Failed with clang?? https://travis-ci.org/tueda/form/builds/253705758 https://travis-ci.org/tueda/form/builds/253705758 (See Issue219.)

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/219#issuecomment-315549444, or mute the thread https://github.com/notifications/unsubscribe-auth/AFLxEl68SGltY3d7AIHR2YKuPQTTK6iuks5sOPaggaJpZM4OVjKn.

tueda commented 7 years ago

It seems that the following code gave an error with clang in macOS on Travis CI:

#$n64  = -2^63;
L F64  = {`$n64'};
P;
.end
tueda commented 7 years ago

You need to turn on the optimization. Probably something hits on an undefined behaviour, which compilers are allowed to discard smartly. In the following link you can play with "Run" with/without "Optimization": https://wandbox.org/permlink/Bhe1uTtaJ4niW9Z5

tueda commented 7 years ago

I guess

if ( answer < 0 ) { answer = -answer; }

is already undefined for answer=-9223372036854775808 (overflow in signed arithmetic). See https://godbolt.org/g/oX98bo, in which gcc completely skips a conditional branch with -O1.