diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-08-04 11:24:40 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-04 11:24:40 +1000 |
| commit | 6c7ffefcbdd883149335a157ad0f5e9851b601a8 (patch) | |
| tree | e3c372c40acb58debfc976d0e41e383a2e1c9aa6 | |
| parent | 21050447841d52196aff65c8ab44e36a338c245b (diff) | |
| parent | 1a64684b0421d9e7090c0f805ef7637d0d6789ba (diff) | |
Rollup merge of #144785 - lucarlig:master, r=lqd
Regression test for LLVM error with unsupported expression in static initializer for const pointer in array on macOS.
Regression test for rust-lang/rust#89225, I have shortened the original example as much as i could, while still generating the error.
here is my output on MacOs:
```
rustup run 1.60 cargo build --release
Compiling rug_int v0.1.0 (/Users/luca/dev/rug_int)
LLVM ERROR: Unsupported expression in static initializer: zext (i64 ptrtoint (<{ [4 x i8] }>* `@anon.fad58de7366495db4650cfefac2fcd61.0` to i64) to i128)
error: could not compile `rug_int`
rustup run 1.61 cargo build --release
Compiling rug_int v0.1.0 (/Users/luca/dev/rug_int)
Finished release [optimized] target(s) in 0.60s
```
| -rw-r--r-- | tests/ui/codegen/unsupported-static-initializer-in-const-array.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/codegen/unsupported-static-initializer-in-const-array.rs b/tests/ui/codegen/unsupported-static-initializer-in-const-array.rs new file mode 100644 index 00000000000..bc94130ee19 --- /dev/null +++ b/tests/ui/codegen/unsupported-static-initializer-in-const-array.rs @@ -0,0 +1,18 @@ +//! LLVM error with unsupported expression in static +//! initializer for const pointer in array on macOS. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/89225>. + +//@ build-pass +//@ compile-flags: -C opt-level=3 + +const fn make() -> (i32, i32, *const i32) { + const V: i32 = 123; + &V as *const i32; + (0, 0, &V) +} + +fn main() { + let arr = [make(); 32]; + println!("{}", arr[0].0); +} |
