From f92f8ee75bf0f4a653218a52698263b559c463a4 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Sun, 18 Sep 2022 10:37:06 +0100 Subject: [PATCH] gccrs: Add testcase for const-eval issue from rust-blog see: https://blog.rust-lang.org/2022/09/15/const-eval-safety-rule-revision.html gcc/testsuite/ChangeLog: * rust/compile/rust-const-blog-issue.rs: New test. --- gcc/testsuite/rust/compile/rust-const-blog-issue.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 gcc/testsuite/rust/compile/rust-const-blog-issue.rs diff --git a/gcc/testsuite/rust/compile/rust-const-blog-issue.rs b/gcc/testsuite/rust/compile/rust-const-blog-issue.rs new file mode 100644 index 0000000..a5ea2eb --- /dev/null +++ b/gcc/testsuite/rust/compile/rust-const-blog-issue.rs @@ -0,0 +1,12 @@ +// { dg-excess-errors "accessing value of" } +mod mem { + extern "rust-intrinsic" { + #[rustc_const_stable(feature = "const_transmute", since = "1.46.0")] + fn transmute(_: T) -> U; + } +} + +pub static FOO: () = unsafe { + let illegal_ptr2int: usize = mem::transmute(&()); + let _copy = illegal_ptr2int; +}; -- 2.7.4