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
Running with cargo run does the right thing and loops forever (since valid is never mutated to be true). Running with cargo run --release gives an ‘illegal hardware instruction’ error:
$ cargo run --release Compiling thing v0.1.0 (/home/me/thing)warning: unused variable: `valid` --> src/main.rs:19:13 |19 | let valid = true; | ^^^^^ help: if this is intentional, prefix it with an underscore: `_valid` | = note: `#[warn(unused_variables)]` on by defaultwarning: unused variable: `valid` --> src/main.rs:24:21 |24 | let valid = false; | ^^^^^ help: if this is intentional, prefix it with an underscore: `_valid`warning: variable does not need to be mutable --> src/main.rs:16:9 |16 | let mut valid = false; | ----^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by defaultwarning: 3 warnings emitted Finished release [optimized] target(s) in 0.89s Running `target/release/thing`zsh: illegal hardware instruction cargo run --release
This happens both when compiling incrementally and when compiling from scratch.
I repeatedly removed more and more elements from the code until I ended up with the following minimal example (it might not function the same, but it still gives the same error):
fnmain(){a();}fna(){loop{loop{}}}
Curiously the ‘illegal hardware instruction’ error goes away if I manually inline a() into main(). Adding #[inline(always)] to a() does not remove the error, though.
I was helping a friend on Advent of Code Day 13 Part 2, and ran this broken (as in doesn’t solve the problem and accidentally loops forever) code:
Cargo.toml
:Running with
cargo run
does the right thing and loops forever (sincevalid
is never mutated to betrue
). Running withcargo run --release
gives an ‘illegal hardware instruction’ error:This happens both when compiling incrementally and when compiling from scratch.
I repeatedly removed more and more elements from the code until I ended up with the following minimal example (it might not function the same, but it still gives the same error):
Curiously the ‘illegal hardware instruction’ error goes away if I manually inline
a()
intomain()
. Adding#[inline(always)]
toa()
does not remove the error, though.Compiling with nightly
or beta
fixes the issue.
The text was updated successfully, but these errors were encountered: