Kronos icon indicating copy to clipboard operation
Kronos copied to clipboard

Correct operator precedence

Open pstef opened this issue 1 year ago • 2 comments

This change is untested but it should work :)

In the previous version, != took precedence over ^ so that (((*A)>>11)&0x1) != 0 was evaluated first and then xored with the left hand side.

Here I remove all the unnecessary parens except the ones suggested by GCC -Wparentheses. And add the parens that are actually needed in order to evaluate !=0 last.

pstef avatar Oct 23 '24 21:10 pstef

I do not know exactly which flag or version of gcc has this issue, i did not dig in the debugging of gcc. Kronos is using gcc since the beginning and inherited lot of those unary operator code from yabause.

We found during fixing that unary usage requires a lot of care with parenthesis. I am not open to remove any parenthesis here. Just add a new one since it may introduce regressions more than fixes.

I agree it is not really readable but it works. If clang is complaining for the equality, just add one parenthesis, not more.

Thanks

FCare avatar Oct 24 '24 06:10 FCare

I've found the flag and corrected the commit, GCC should not be complaining. Would it be ok for you as it is now?

pstef avatar Oct 24 '24 06:10 pstef