]> git.ipfire.org Git - thirdparty/valgrind.git/commit
Fix this test to work properly with accurate CmpEQ/NE definedness tracking
authorJulian Seward <jseward@acm.org>
Thu, 7 Dec 2017 12:31:38 +0000 (13:31 +0100)
committerJulian Seward <jseward@acm.org>
Thu, 7 Dec 2017 12:31:38 +0000 (13:31 +0100)
commit0e7c46401bd3a3094459d8ea5231906caaf862a8
tree758e2c602b72ffa784dcc4f5b79ba7a1a8b79edb
parent8a2acb304db99c0760de32b684e2ec09b7e52bd2
Fix this test to work properly with accurate CmpEQ/NE definedness tracking

Memcheck reports an error on "if (n == 42)" in this test.  Unless, that is,
accurate CmpEQ/NE definedness tracking is enabled.  If you stare at this
long enough it is possible to see that the test "n == 42" isn't actually
undefined, because |n| is only ever zero or one, and only its least
significant bit is undefined.  So the equality comparison against 42 is
defined because there are corresponding bits in the two operands that are
different and are both defined.

This commit fixes that by comparing with 1, which forces the result to
really depend on the only undefined bit in |n|.

I also added robustification:

* return arbitrary values from gcc_cant_inline_me(), so as to avoid gcc
  simply copying the input to the output or otherwise deleting the
  conditional branch.

* marking gcc_cant_inline_me() as un-inlineable

* Putting compiler barriers in the second conditional in main(), so gcc
  can't simply ignore the result of the call to gcc_cant_inline_me() and
  then delete the call entirely.
memcheck/tests/manuel3.c