Closed
Description
Description
Operator "==" works fine for initializing constexpr parameters for simple types. However, incorrect code is generated for types that initialized via initializer_list or for types with complex (with more then one parameters) constructor.
To reproduce
x : int = 1;
xc : int == 1;
a : std::array = (1,2,3);
ac : std::array == (4,5,6);
v: std::vector = (1,2,3);
vc: std::vector == (1,2,3);
t : mytype = (5,6,7);
tc : mytype == (5,6,7);
Generates
int x {1};
int constexpr xc = 1; //OK
std::array a {1, 2, 3};
std::array constexpr ac = (4, 5, 6); //BUG
std::vector v {1, 2, 3};
std::vector constexpr vc = (1, 2, 3); //BUG
mytype t {5,6,7};
mytype constexpr tc = (5, 6, 7); //BUG
Expected result
int x {1};
int constexpr xc = 1;
std::array a {1, 2, 3};
std::array constexpr ac{4, 5, 6};
std::vector v {1, 2, 3};
std::vector constexpr vc{1, 2, 3};
mytype t {5,6,7};
mytype constexpr tc{5,6,7};
Additional context
Trunk version of cppfront at godbolt.org