Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupted characters in {-9223372036854775808} #219

Closed
tueda opened this issue Jul 12, 2017 · 5 comments
Closed

Corrupted characters in {-9223372036854775808} #219

tueda opened this issue Jul 12, 2017 · 5 comments
Labels
bug Something isn't working

Comments

@tueda
Copy link
Collaborator

tueda commented Jul 12, 2017

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 tueda added the bug Something isn't working label Jul 14, 2017
@tueda
Copy link
Collaborator Author

tueda commented Jul 15, 2017

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

@vermaseren
Copy link
Owner

vermaseren commented Jul 15, 2017 via email

@tueda
Copy link
Collaborator Author

tueda commented Jul 15, 2017

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
Copy link
Collaborator Author

tueda commented Jul 15, 2017

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
Copy link
Collaborator Author

tueda commented Jul 15, 2017

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.

tueda added a commit that referenced this issue Jul 16, 2017
This doesn't rely on any undefined behaviour of C, I believe.
See #139 and #219.
tueda added a commit that referenced this issue Jul 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants