https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116476
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |jason at gcc dot gnu.org
Last reconfirmed| |2024-08-24
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced further:
#include <initializer_list>
template <class T>
struct field {
field(T &&) {}
};
struct vector {
vector(std::initializer_list<field<int>>) { }
};
vector fields_normal{2}; // Error
init.cc:11:23: error: binding reference of type 'int&&' to 'const int' discards
qualifiers
11 | vector fields_normal{2}; // Error
| ^
init.cc:5:11: note: initializing argument 1 of 'field<T>::field(T&&) [with T
= int]'
5 | field(T &&) {}
| ^~~~
init.cc: In function 'void __static_initialization_and_destruction_0()':
init.cc:11:23: error: cannot bind rvalue reference of type 'int&&' to lvalue of
type 'const int'
11 | vector fields_normal{2}; // Error
| ^
init.cc:5:11: note: initializing argument 1 of 'field<T>::field(T&&) [with T
= int]'
5 | field(T &&) {}
| ^~~~
Regression started with r14-1705:
c++: build initializer_list<string> in a loop [PR105838]