Skip to content

Fix array support (-Oarray optimization)#143

Open
alastairreid wants to merge 4 commits intomasterfrom
areid/array-return
Open

Fix array support (-Oarray optimization)#143
alastairreid wants to merge 4 commits intomasterfrom
areid/array-return

Conversation

@alastairreid
Copy link
Copy Markdown

@alastairreid alastairreid commented Apr 27, 2026

This transformation fixes array support by wrapping arrays in structs.
This works because C does not support array assignment (because arrays are promoted to pointers) but it does support struct assignment.

Fixes #41

This change makes it easier to figure out the type of array literals
which is required for the array wrapping transformation xform_array.
This transformation wraps arrays in records.
The purpose of this is to simplify C code generation which was
incorrectly generating 'x = y;' to copy an array.
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.

Bug: returning arrays from functions generates hilariously bad C code

1 participant