-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed as not planned
Labels
C-gubCategory: the reverse of a compiler bug is generally UBCategory: the reverse of a compiler bug is generally UB
Description
I tried this code:
if status == napi_ok {
eprintln!("[reproduce] status == napi_ok, should not error");
} else {
eprintln!("[reproduce] status != napi_ok, should be error");
}
if status != napi_ok {
unsafe {
napi_throw_error(env, null_mut(), c"[reproduce] Error: status != napi_ok".as_ptr());
}
return null_mut();
}
let result = MaybeUninit::<napi_value>::uninit();
I expected to see this happen: explanation
X == 0
and X != 0
can not be both triggered
=== Calling debug reproduce ===
[reproduce] status == napi_ok, should not error
=== Calling release workaround ===
[workaround] status == napi_ok, should not error
Instead, this happened: explanation
X == 0
and X != 0
can be both triggered
=== Calling release reproduce ===
[reproduce] status == napi_ok, should not error
Error: [reproduce] Error: status != napi_ok
at Object.<anonymous> (/workspaces/loynoir/repo/reproduce-rust-145163/reproduce.js:9:15)
at Module._compile (node:internal/modules/cjs/loader:1738:14)
at Object..js (node:internal/modules/cjs/loader:1871:10)
at Module.load (node:internal/modules/cjs/loader:1470:32)
at Module._load (node:internal/modules/cjs/loader:1290:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:238:24)
at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
at node:internal/main/run_main_module:33:47
workaround
let result = MaybeUninit::<napi_value>::uninit();
let result = MaybeUninit::<[napi_value; 1]>::uninit();
Meta
rustc --version --verbose
:
$ rustc --version --verbose
rustc 1.91.0-nightly (ec7c02612 2025-08-05)
binary: rustc
commit-hash: ec7c02612527d185c379900b613311bc1dcbf7dc
commit-date: 2025-08-05
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 20.1.8
Backtrace
<backtrace>
reproduce
Metadata
Metadata
Assignees
Labels
C-gubCategory: the reverse of a compiler bug is generally UBCategory: the reverse of a compiler bug is generally UB