rust/tests/run-make/raw-fn-pointer-opt-undefined-behavior/rmake.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
596 B
Rust
Raw Normal View History

// Despite the absence of any unsafe Rust code, foo.rs in this test would,
// because of the raw function pointer,
// cause undefined behavior and fail to print the expected result, "4" -
// only when activating optimizations (opt-level 2). This test checks
// that this bug does not make a resurgence.
// Note that the bug cannot be observed in an assert_eq!, only in the stdout.
// See https://github.com/rust-lang/rust/issues/20626
//@ ignore-cross-compile
use run_make_support::{run, rustc};
fn main() {
rustc().input("foo.rs").opt().run();
run("foo").assert_stdout_equals("4");
}