You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
davidlattimore opened this issue
Sep 8, 2018
· 1 comment
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
pubfnbar(i:i32) -> i32{if i < 1000{bar(i % 2)}else{1234567}}fnmain(){println!("RESULT: {}", bar(10));}
If I cargo run this, I get a stack overflow as expected. If I cargo run --release however, I get:
RESULT: 1234567
The else should be unreachable (with input 10). I suspect LLVM is correctly identifying that it will recurse indefinitely, but that it perhaps considers that undefined behavior, so decides that it's free to remove the if statement and just unconditionally return the constant value. Indeed, if I look at the assembly produced for bar, it's just:
movl$1234567, %eax retq
rustc version 1.28.0
The text was updated successfully, but these errors were encountered:
Centril
added
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
labels
Sep 8, 2018
A duplicate of #18785. I’m surprised we ended up closing #18785 without really checking whether the underlying reason is the same. I’ll reopen that issue and close this in favour of that.
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
If I cargo run this, I get a stack overflow as expected. If I cargo run --release however, I get:
RESULT: 1234567
The else should be unreachable (with input 10). I suspect LLVM is correctly identifying that it will recurse indefinitely, but that it perhaps considers that undefined behavior, so decides that it's free to remove the if statement and just unconditionally return the constant value. Indeed, if I look at the assembly produced for bar, it's just:
rustc version 1.28.0
The text was updated successfully, but these errors were encountered: