Skip to content

Can't assign non-const in array initialization #469

Open
@AGraber

Description

@AGraber

Issue description:

For some reason, new array[2] = anotherArray; is wrong and gives an error: must be a constant expression; assumed zero. I have to then resort to this: new array[2]; array2 = anotherArray;. which achieves the desired result. Now, I understand this was made on purpose, but does it really need to be like that? This just complicates syntax for something that is valid in virtually any other language.

Minimal complete verifiable example (MCVE):

new anotherArray[2] = {1, 2};
main()
{
    new array[2] = anotherArray; // must be a constant expression; assumed zero
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions