Skip to content

cgen: fix fixed array return via local#27350

Merged
medvednikov merged 1 commit into
masterfrom
codex/fix-fixed-array-return-local-clean
Jun 5, 2026
Merged

cgen: fix fixed array return via local#27350
medvednikov merged 1 commit into
masterfrom
codex/fix-fixed-array-return-local-clean

Conversation

@medvednikov

Copy link
Copy Markdown
Member

Summary

Fixes #27345.

  • Copy fixed-array identifier returns from the raw local array instead of reading .ret_arr from it.
  • Add a regression test for returning a fixed array through an intermediate local initialized from another fixed-array-returning function.

Root Cause

Fixed-array function returns use a wrapper struct with a .ret_arr field in generated C, but ordinary local fixed-array variables are raw C arrays. The return path was using the fixed-array return-wrapper type metadata to decide that an identifier return should read local.ret_arr, which is invalid for raw local arrays.

Validation

  • ./v -g -keepc -o ./vnew cmd/v
  • issue repro with ./vnew run /tmp/.../repro.v
  • ./vnew -silent test vlib/v/tests/return_fixed_array_test.v
  • ./vnew -silent vlib/v/gen/c/coutput_test.v

@medvednikov medvednikov merged commit a74d932 into master Jun 5, 2026
86 of 93 checks passed
dy-tea pushed a commit to wenxuanjun/v that referenced this pull request Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cgen: fixed array return via local emits .ret_arr on raw array

1 participant