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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Nick Krempel from comment #0)
> The following code should fail to compile but does not:
> 
> struct V {};
> struct B : private virtual V {};
> struct D : B {};
> 
> int main() {
>       D d;
> }
> 
> According to N3376 section 12.1 paragraph 5, the defaulted default
> constructor for D should be defined as deleted, as the default constructor
> for the virtual base V is inaccessible from D.

MSVC rejects this example, GCC, Clang and EDG accept it.

Oddly, Clang rejects it if ~V is user provided:

struct V { ~V() {} };
struct B : private virtual V {};
struct D : B {};
D d;

I have no idea why that makes a difference. GCC and EDG still accept that.

Clang doesn't care if V() is user provided, it will use it either way. It will
use ~V() if it's defined as deleted on its first declaration. It only rejects
it if ~V() is user provided.

I still don't know what the correct behaviour is.

Reply via email to