Incorrect behavior on C function that returns struct which contains array of one or two doubles #21245
Labels
arch-aarch64
64-bit ARM
arch-riscv
32-bit and 64-bit RISC-V
arch-wasm
32-bit and 64-bit WebAssembly
arch-x86_64
64-bit x86
bug
Observed behavior contradicts documented or intended behavior
miscompilation
The compiler reports success but produces semantically incorrect code.
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Zig Version
0.14.0-dev.1349+6a21875dd
Steps to Reproduce and Observed Behavior
Consider the following C struct and function:
Equivalently, the
test_function
can be implemented in Zig as follows:In either case, the functions may be invoked as follows:
The code is built on an Ubuntu 22.04 without additional flags via
zig build
. The behavior is as follows:I attach a minimum reproducible case (minimum_case.zip) that contains the code I've used. Should be as straightforward as downloading the zip and running
zig build run
.For context, the error has come up while trying to wrap a C library that uses complex values, stored as this struct of an array of two elements.
Expected Behavior
For the struct to be correctly returned.
The text was updated successfully, but these errors were encountered: