Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect operator precedence #97

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

szsam
Copy link
Contributor

@szsam szsam commented Mar 25, 2024

Before this commit, if __optr is == or !=, the if condition on line 1052 is unintendedly interpreted as

((real_t)(opndv1.data.integer __optr opndv2.data.integer) == (real_t)opndv1.data.integer)
    __optr
(real_t)opndv2.data.integer

because the associativity of != and == operators in C is left-to-right. Fixed by fully parenthesize the complex comparison expression.

Before this commit, if __optr is == or !=, the if condition on line 1052
is unintendedly interpreted as
  ((real_t)(opndv1.data.integer __optr opndv2.data.integer) == (real_t)opndv1.data.integer)
    __optr
  (real_t)opndv2.data.integer
because the associativity of != and == operators in C is left-to-right.
Fixed by fully parenthesize the complex comparison expression.
@paladin-t paladin-t merged commit 0326331 into paladin-t:master Mar 26, 2024
1 check passed
paladin-t added a commit that referenced this pull request Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants