Skip to content

Instantly share code, notes, and snippets.

@rom1v
Last active April 27, 2018 05:34
Show Gist options
  • Save rom1v/976c686abbe860450dd9335ded5e3d40 to your computer and use it in GitHub Desktop.
Save rom1v/976c686abbe860450dd9335ded5e3d40 to your computer and use it in GitHub Desktop.
Infinite loop that terminates (in Rust)
fn f(b: bool) -> bool {
loop {
if b {
return true
}
}
// false
}
fn main() {
print!("{}", f(false));
}
$ 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