-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Incorrect optimization in code fragment #18786
Comments
Is that code sample the right one? |
I have reduced the code to this : fn main() {
for d in range(0u, 1) {
let u: uint = (d + 1) % 2;
let mut x = [0i,..2];
let mut mask = false;
while x[u] < 2 {
mask = x[1] > 0;
x[u] += 1;
}
println!("This should be true: {}" , mask);
if !mask {
panic!("Failed!");
}
}
} runs fine when compiled with |
Whoops, I'm not sure why my link didn't work. Obviously I didn't find a bug in Hello World :). I fixed the link. |
It appears that the code is too long for a get request which is why play doesn't work. |
Is it worth marking this as a release blocker? Incorrect optimizations seem like a big deal that should be fixed before 1.0. |
This code sample now prints 'true' in both cases, with no panic. |
I found some code that behaves differently with optimization. With -O0, it prints false; with any higher setting, it prints true.
Sorry about the poor variable names; this is (mostly) a translation from some Javascript code. I've tried to remove as much code as I can, but I'm sure it can still be reduced somewhat and still show the same incorrect behavior.
Edit: the old code sample linked to 'hello world' for some reason. I fixed it.
The text was updated successfully, but these errors were encountered: