Skip to content

Commit

Permalink
Fix for issue #52
Browse files Browse the repository at this point in the history
Multiplication has higher precedence than ternary operator. So `a[0] * numElems` is computed first and used as the 1st operand of `?:`. This seems semantically wrong and also causes the warning (because the 1st operand of `?:` has boolean context). Parntheses around "a[0]" are not actually required, but with these the code looks clearer to me.
  • Loading branch information
atamazov authored Aug 30, 2018
1 parent a0d5fe6 commit 33b4c44
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libHSAIL/HSAILBrigObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class WriteAdapter : public virtual IOAdapter {

template <typename T, unsigned N>
int write(const T (&a)[N], unsigned numElems = 0) {
return write((const char*)a, sizeof a[0] * numElems? numElems : N);
return write((const char*)a, sizeof(a[0]) * (numElems != 0 ? numElems : N));
}
};

Expand Down

0 comments on commit 33b4c44

Please sign in to comment.