Skip to content

[BUG] constexpr initialization for std::array #1104

@MaxSagebaum

Description

@MaxSagebaum

It seems that constexpr initalization is generated the wrong way.

var : std::array<char, 5> == "abcd";

is lowered to

std::array<char,5> constexpr var = "abcd";

which results into the error:

main.cpp2:8:34: error: no viable conversion from 'const char[5]' to 'const std::array<char, 5>'

The correct lowering in this case would be:

std::array<char, 5> constexpr var {"abcd"};

this version, without the constexpr, is used for var : std::array<char, 5> = "abcd";.

Reproducer:
https://cpp2.godbolt.org/z/KbPvxPdoq

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions