-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-ZSTArea: Zero-sized types (ZSTs).Area: Zero-sized types (ZSTs).C-bugCategory: This is a bug.Category: This is a bug.F-autodiff`#![feature(autodiff)]``#![feature(autodiff)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
#![feature(autodiff)]
#[core::autodiff::autodiff_forward(fd_inner, Const, Dual)]
fn f(_zst: (), _x: &mut f64) {}
#[unsafe(no_mangle)]
pub extern "C" fn fd(x: &mut f64, xd: &mut f64) {
fd_inner((), x, xd);
}
with this Cargo.toml
:
[package]
name = "x"
edition = "2024"
[profile.dev]
lto = "fat"
panic = "abort"
[lib]
crate-type = ["staticlib"]
and RUSTFLAGS="-Zautodiff=Enable" cargo +enzyme build
. I got the attached ICE.
rustc-ice-2025-07-16T13_26_31-14135.txt
The error goes away if I use a non-ZST, like u8
, as the argument. I can produce various different ICEs (e.g. failing the assert on line 174) by varying the conditions, but my (uneducated) guess is that the root cause is the same, that the autodiff code fails to take into account how ZSTs are translated into LLVM.
Meta
rustc --version --verbose
:
rustc 1.90.0-nightly (c8780fff6 2025-07-11)
binary: rustc
commit-hash: c8780fff6a1f3bda416231342fae0dde986ada39
commit-date: 2025-07-11
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Metadata
Metadata
Assignees
Labels
A-ZSTArea: Zero-sized types (ZSTs).Area: Zero-sized types (ZSTs).C-bugCategory: This is a bug.Category: This is a bug.F-autodiff`#![feature(autodiff)]``#![feature(autodiff)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.