This is an archive of the discontinued LLVM Phabricator instance.

[LLD] Remove assert from Relocations.h
ClosedPublic

Authored by zturner on Dec 16 2016, 1:29 PM.

Details

Summary

This is triggering the following warning:

In file included from D:\src\llvm\tools\lld\ELF\Relocations.cpp:44:
D:\src\llvm\tools\lld\ELF/Relocations.h(101,28):  error: comparison of constant 64 with expression of type 'lld::elf::RelExpr' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
  assert(0 <= Expr && Expr < 64 && "RelExpr is too large for 64-bit mask!");
                      ~~~~ ^ ~~
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\assert.h(33,17):  note: expanded from macro 'assert'
            (!!(expression)) ||                                                              \
                ^~~~~~~~~~

which kills my -Werror build. Since ubsan should catch cases of values larger than 64 being passed in, it seems like the assert might not be strictly necessary. Either way, we need some way to get rid of this warning.

Diff Detail

Event Timeline

zturner updated this revision to Diff 81788.Dec 16 2016, 1:29 PM
zturner retitled this revision from to [LLD] Remove assert from Relocations.h.
zturner updated this object.
zturner added reviewers: ruiu, joerg, silvas.
zturner added a subscriber: llvm-commits.
ruiu edited edge metadata.Dec 16 2016, 1:33 PM

What does -Wtautological-constant-out-of-range-compare do? This assert is to prevent future programmers error, so it is always true, and that's not wrong. Sean added this assert, and I don't think we want to get rid of it.

joerg edited edge metadata.Dec 16 2016, 1:33 PM

Depending on sanitizers to enforce constraints is bogus. They don't work everywhere. *sigh* Guess we have to cast it to int explicitly.

joerg requested changes to this revision.Dec 16 2016, 1:33 PM
joerg edited edge metadata.
This revision now requires changes to proceed.Dec 16 2016, 1:33 PM
zturner updated this revision to Diff 81792.Dec 16 2016, 1:41 PM
zturner edited edge metadata.
ruiu accepted this revision.Dec 16 2016, 2:20 PM
ruiu edited edge metadata.

LGTM

This revision was automatically updated to reflect the committed changes.