This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Fix itostr handling of min int64_t value
ClosedPublic

Authored by thopre on Jun 19 2020, 8:37 AM.

Details

Summary

UBSan buildbot caught an undefined behavior in itostr with INT64_MIN.
The negation cannot be represented in the promoted operand (long long).
Negation is well defined on unsigned value though so this commit does
the negation after the static cast.

Diff Detail

Event Timeline

thopre created this revision.Jun 19 2020, 8:37 AM
lattner accepted this revision.Jun 19 2020, 8:57 AM

nice catch, thanks

This revision is now accepted and ready to land.Jun 19 2020, 8:57 AM
This revision was automatically updated to reflect the committed changes.

Shouldn't there be some unit testing for this? It seems like a better testing method than relying on an UBSan build bot failure that might not manifest again in the future if some other testing were changed.

Shouldn't there be some unit testing for this? It seems like a better testing method than relying on an UBSan build bot failure that might not manifest again in the future if some other testing were changed.

Will do, mind if I add you as reviewer?

Shouldn't there be some unit testing for this? It seems like a better testing method than relying on an UBSan build bot failure that might not manifest again in the future if some other testing were changed.

Will do, mind if I add you as reviewer?

That's fine by me.