[Lldb-commits] [PATCH] D131312: [LLDB][NFC] Fix suspicious bitwise expression in PrintBTEntry()

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 8 01:45:08 PDT 2022


DavidSpickett added a comment.

The original change was https://reviews.llvm.org/D29078. Are you able to run the tests with this applied?



================
Comment at: lldb/tools/intel-features/intel-mpx/cli-wrapper-mpxtable.cpp:66
 
-  if ((lbound == one_cmpl64 || one_cmpl32) && ubound == 0) {
     result.Printf("Null bounds on map: pointer value = 0x%" PRIu64 "\n", value);
----------------
hawkinsw wrote:
> According to https://en.cppreference.com/w/cpp/language/operator_precedence, I would read the left operand of the `&&` as 
> 
> 1. The `==` has higher precedence than `||` so, `b = (lbound == one_compl64)`
> 2. `b || one_cmpl32`
> 
> which does not seem like what the original author intended. I absolutely think that the fix is correct, but I just wanted to get everyone's feedback on whether this seems like more than just a "suspicious bitwise expression" (and more like a "mistaken bitwise expression").
> 
> All that said, I could be completely, 100% wrong. And, if I am, feel free to ignore me!
The corrected code also makes sense given that MPX is some kind of memory protection across ranges.

If `((lbound == one_cmpl64 || lbound == one_cmpl32) && ubound == 0)` is true then upper bound < lower bound making an invalid range. Which is what I'd expect for some default/uninitialised state (especially if zero size ranges are allowed, so upper == 0 and lower == 0 couldn't be used).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131312/new/

https://reviews.llvm.org/D131312



More information about the lldb-commits mailing list