https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115114
Bug ID: 115114
Summary: aggregate initialization with parens fails when there
is a base class
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: eric.niebler at gmail dot com
Target Milestone: ---
I believe the following is valid C++20:
struct get_answer {};
template <class Query, class Value>
struct with : Query {
Value value;
};
int main() {
with w1{get_answer(), 42}; // works
with w2(get_answer(), 42); // fails
}
clang and msvc accept this code. gcc-trunk rejects it. See
https://godbolt.org/z/KvGjn47f9.
If I change the definition of the `with` class template to the following, the
code compiles:
template <class Query, class Value>
struct with {
Query query;
Value value;
};