File: const_fn_target_feature.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg2-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 893,176 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (20 lines) | stat: -rw-r--r-- 647 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//@ only-x86_64
// Set the base cpu explicitly, in case the default has been changed.
//@ compile-flags: -C target-cpu=x86-64 -C target-feature=+ssse3
//@ check-pass

#![crate_type = "lib"]

// ok (ssse3 enabled at compile time)
const A: () = unsafe { ssse3_fn() };

// error (avx2 not enabled at compile time)
const B: () = unsafe { avx2_fn() };
// FIXME: currently we do not detect this UB, since we don't want the result of const-eval
// to depend on `tcx.sess` which can differ between crates in a crate graph.

#[target_feature(enable = "ssse3")]
const unsafe fn ssse3_fn() {}

#[target_feature(enable = "avx2")]
const unsafe fn avx2_fn() {}