This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][NFC] Avoid implicit-integer-sign-change in FuzzedDataProvider::ConsumeIntegralInRange
ClosedPublic

Authored by MarcoFalke on Jul 13 2023, 7:34 AM.

Details

Summary

This makes the implicit conversion that is happening explicit.
Otherwise, each user is forced to suppress this
implicit-integer-sign-change runtime error in their their UBSAN
suppressions file.

For example, the runtime error might look like:

runtime error: implicit conversion from type 'long' of value -9223372036854775808 (64-bit, signed) to type 'uint64_t' (aka 'unsigned long') changed the value to 9223372036854775808 (64-bit, unsigned)
    #0 0x55fe29dea91d in long FuzzedDataProvider::ConsumeIntegralInRange<long>(long, long) src/./test/fuzz/FuzzedDataProvider.h:233:25
    [...]
 SUMMARY: UndefinedBehaviorSanitizer: implicit-integer-sign-change test/fuzz/FuzzedDataProvider.h:233:25 in

Diff Detail

Event Timeline

MarcoFalke created this revision.Jul 13 2023, 7:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 7:34 AM
Herald added subscribers: Enna1, dberris. · View Herald Transcript
MarcoFalke requested review of this revision.Jul 13 2023, 7:34 AM

Fix both places

This revision was not accepted when it landed; it landed in state Needs Review.Jul 17 2023, 12:33 AM
This revision was automatically updated to reflect the committed changes.

I went ahead and merged this, because it should be trivially correct. Feel free to revert or let me know if there are any issues.