https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98639

--- Comment #5 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
Meh, I guess this is just an unintended (but conforming) consequence of the
shifting C++17/20 rules. Jonathan links to
https://twitter.com/wakomeup/status/1274778577087627267 as another example:

// https://godbolt.org/z/WWr9b8 
Base b;
const Derived& rd = b; // ill-formed forever, I hope
const Derived& rd{b};  // ill-formed until '14, OK in '17 and later
const Derived& rd(b);  // ill-formed until '17, OK in '20 and later

It remains _surprising_ that you can make a `Derived` out of a `Base` in the
absence of a constructor... but that's just the new aggregate-paren-init rules
at work.
It remains _surprising_ that you can bind a `const Derived&` to a `Base&`
without a cast... but that's just the interaction of lifetime extension with
the new aggregate-init rules.

I do think it'd be nice for GCC to give some sort of diagnostic here. But I
guess it would have to be an opt-in diagnostic switch. And we already have that
switch today; it's called `-std=c++17`. ;)  So maybe there's really no way to
improve the situation here at all, and this can be closed as NOTABUG.

Reply via email to