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

WARN: Logical expression, do not apply the second operand if not needed? #31

Open
keyvank opened this issue Oct 25, 2024 · 2 comments
Open

Comments

@keyvank
Copy link
Owner

keyvank commented Oct 25, 2024

Imagine these two if statements:

if(false && f()) {
}
if(true && f()) {
}

in 30cc, f() is evaluated twice, thus its side-effects are applied twice, but in regular C, only the f() in the second if-statement is applied.

@keyvank keyvank changed the title WARN: Logical expression, do not apply of not needed? WARN: Logical expression, do not apply the second operand if not needed? Nov 25, 2024
@ookami125
Copy link
Contributor

I have a hackish implementation of short circuiting here while this contains some stuff from my refactor I think the general idea should still work of breaking out the short circuiting things out into a new function and processing everything there. It was basically a copy of the normal function, chop out all the unneeded bits and then shit the binop->right->apply till after the result of the left has been checked.

@keyvank
Copy link
Owner Author

keyvank commented Dec 12, 2024

@ookami125 Thanks! Please make this a PR! :)

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

No branches or pull requests

2 participants