Skip to content

Bug: returning arrays from functions generates hilariously bad C code #41

Open
@alastairreid

Description

@alastairreid

Two issues

  1. The function prototype is "T F32" which is the type of an array of functions that return T.
  2. The value is returned by "return result;" where result is an array. This just returns the address of the array.

The fix is probably to do the same that we do for FFI functions: pass in a pointer to where the result should go

    void F(T result[32]) {...}

An alternative might be to adapt the tuple return code to put the array in a struct the same way that we do if the return type is a tuple.

    struct F_result { T r0[32]; };
    struct F_result F() {...}

The second might be easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions