On 10/25/2015 09:04 PM, Ville Voutilainen wrote:
On 25 October 2015 at 22:15, Ville Voutilainen
<ville.voutilai...@gmail.com> wrote:
It seems to me that there's a discrepancy in handling explicit
default constructors. Based on my tests, this works:
struct X {explicit X() {}};
void f(X) {}
int main()
{
f({});
}
However, if the explicit constructor is defaulted, gcc accepts the code:
struct X {explicit X() = default;};
void f(X) {}
int main()
{
f({});
}
And to clarify, I'd expect both of those snippets to be rejected, but only the
former is.
The latter is accepted because the second X is an aggregate, and the
aggregate initialization bullet comes before value-initialization in 8.5.4.
Jason