It does not compile in any major compiler. It will compile until an object of type Y is created.
If you create an object of type Y , the output of clang will be
error: call to implicitly-deleted default constructor of 'Y' note: explicitly defaulted function was implicitly deleted here Y() = default; note: default constructor of 'Y' is implicitly deleted because field 'x' of reference type 'X &' would not be initialized X& x;
When you declare a user-defined constructor, which is just an empty function, there is an error without creating an object.
Michael Burr is right. An implicit default constructor works fine. No diagnostic problems here, as I see.
source share