-
-
Save rom1v/976c686abbe860450dd9335ded5e3d40 to your computer and use it in GitHub Desktop.
Infinite loop that terminates (in Rust)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn f(b: bool) -> bool { | |
loop { | |
if b { | |
return true | |
} | |
} | |
// false | |
} | |
fn main() { | |
print!("{}", f(false)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rustc -O a.rs && ./a | |
Illegal instruction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment