[cfe-dev] Warning for explicitly defaulted special members that end up being deleted ?

Matthieu Monrocq matthieu.monrocq at gmail.com
Thu Apr 18 01:27:51 PDT 2013


Hello,

A question popped up on SO today [1]: the OP was quite surprised that he
could write:

struct X {};

struct Y {
    Y() = default;
    X& x;};

And not have any compiler complain about the above code.

Of course, as has been answered, only the instantiation of Y (and thus use
of the default constructor) should actually cause an issue; and there is
even a clause that the `= default` can be turned automatically
(semantically wise) in a `= delete` in some cases (such as this one).


Still, even though this is probably very useful for template classes, it is
surprising to say the least; and generally being warned earlier is better.
Therefore I was wondering if there is a warning in Clang when an
*explicitly* defaulted special member is *deleted* by the compiler.

I could not find it, if there is (but then there are many warnings to sift
through so I might have missed it). Does anyone knows about it ?

-- Matthieu

[1]: http://stackoverflow.com/a/16076878/147192
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130418/9b95d411/attachment.html>


More information about the cfe-dev mailing list