Skip to content

emit-c: an array-of-arrays literal in a function body does not compile (rows named inside an initializer list) #1771

Closed

Description

@ehartford

Found while fixing #1484 (pcre2's [[u8; 21]; 17] tables, initialized at startup by that fix, hit it first).

--emit-c of an array-of-arrays literal in a function body emits C that does not compile:

fn main:
    let t = [[1, 2], [3, 4]]
    print(t[1][0])

The aggregate assignment renders every row by name inside an initializer list ({ int32_t __with_arr_tmp[2][2] = {_1, _2}; memcpy(...); }); a row is a C array, so clang reports incompatible pointer to integer conversion initializing 'int32_t' with an expression of type 'int32_t[2]'. The LLVM backend prints 3.

Expected: each row is copied into the temporary (memcpy per row), then the temporary into the destination.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions