This is an archive of the discontinued LLVM Phabricator instance.

[ubsan] Detect invalid unsigned pointer index expression (compiler-rt)
ClosedPublic

Authored by vsk on Jun 5 2017, 12:57 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

vsk created this revision.Jun 5 2017, 12:57 PM
regehr added inline comments.Jun 5 2017, 1:03 PM
test/ubsan/TestCases/Pointer/unsigned-index-expression.cpp
6 ↗(On Diff #101448)

I don't know that it matters too much in practice but it may be better to make p a valid pointer instead of casting 7 into a pointer, which is at best implementation defined behavior.

vsk updated this revision to Diff 101496.Jun 5 2017, 5:55 PM
  • Avoid implementation-defined behavior in the test.
  • Fix the signed-ness check: to check that the sign bit is off, we need 'x >= 0'. Caught by running check-ubsan.
This revision was automatically updated to reflect the committed changes.