This is an archive of the discontinued LLVM Phabricator instance.

LLD: Fix large integer implicitly truncated to unsigned type warning
ClosedPublic

Authored by kzhuravl on Oct 23 2017, 9:26 AM.

Details

Reviewers
ruiu
Summary

Patch by @b-sumner

Diff Detail

Event Timeline

kzhuravl created this revision.Oct 23 2017, 9:26 AM
ruiu edited edge metadata.Oct 23 2017, 9:44 AM

Both Clang and MSVC don't emit a warning on this code. What compiler are you using?

g++4.8.2 is complaining:

../../../InputSection.h: In constructor 'lld::elf::SectionPiece::SectionPiece(size_t, uint32_t, bool)':
../../../InputSection.h:219:41: error: large integer implicitly truncated to unsigned type [-Werror=overflow]

Live(Live || !Config->GcSections) {}
                                ^
ruiu added a comment.Oct 23 2017, 9:58 AM

Thanks, I confirmed.

Since we have plenty bits for OutputOff, changing the type of OutputOff from uint64_t to int64_t seems better than using an obscure very large constant.

kzhuravl updated this revision to Diff 119889.Oct 23 2017, 10:03 AM

Address review feedback.

ruiu accepted this revision.Oct 23 2017, 10:07 AM

LGTM

Please mention that this fixes a gcc warning.

This revision is now accepted and ready to land.Oct 23 2017, 10:07 AM