This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Avoid signed overflow in floatdidf.c and floatdisf.c
ClosedPublic

Authored by Ka-Ka on Mar 15 2023, 6:14 AM.

Details

Summary

When compiling compiler-rt with -fsanitize=undefined and running testcases you
end up with the following warning:

UBSan: floatdisf.c:27:15: signed integer overflow: 9223372036854775807 - -1 cannot be represented in type 'di_int' (aka 'long long')

This can be avoided by doing the subtraction in a matching unsigned variant of
the type, given that the overflow is the expected result of the subtraction.

The same kind of pattern exists in floatdidf.c

This was found in an out of tree target.

Diff Detail

Event Timeline

Ka-Ka created this revision.Mar 15 2023, 6:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2023, 6:14 AM
Herald added subscribers: Enna1, dberris. · View Herald Transcript
Ka-Ka requested review of this revision.Mar 15 2023, 6:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2023, 6:14 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
phosek accepted this revision.Mar 16 2023, 12:16 AM

LGTM

This revision is now accepted and ready to land.Mar 16 2023, 12:16 AM
This revision was landed with ongoing or failed builds.Mar 17 2023, 12:15 AM
This revision was automatically updated to reflect the committed changes.