Re:Unexpected Ways Memory Subsystem Interacts with Branch Pr...
by inetknght on Friday December 29, 2023 @12:26PM
(#38807614)
cnt += a[i]
No, you've changed the right-hand side expression. Now you're adding a[i] to cnt and nowhere has it stated that a[i] is 1. But a[i] > 0's result is always zero or one.
I suggest what you want is this:
cnt += !!a[i]
Now, a[i] is not-notted -- the expression returns a bool indicating whether the value is converted to true.
No, you've changed the right-hand side expression. Now you're adding a[i] to cnt and nowhere has it stated that a[i] is 1. But a[i] > 0's result is always zero or one.
I suggest what you want is this:
Now, a[i] is not-notted -- the expression returns a bool indicating whether the value is converted to true.or this, depending on your style:
which does the same thing