https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106040
Bug ID: 106040
Summary: gcc reports error in aggregate when member has
explicit constructor
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ldalessandro at gmail dot com
Target Milestone: ---
gcc fails to compile the following example, as it seems to be treating .i{0} as
an implicit operation rather than an explicit construction. Both clang and MSVC
accept the example.
struct foo {
explicit foo(int) {}
};
struct bar {
foo i;
};
bar x {
.i{0} // <-- error:
};
error: <source>:11:1: error: converting to 'foo' from initializer list would
use explicit constructor 'foo::foo(int)'
live: https://godbolt.org/z/hhvnGaK6c