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

David Blaikie dblaikie at gmail.com
Thu Apr 18 01:36:04 PDT 2013


On Apr 18, 2013 6:30 PM, "Matthieu Monrocq" <matthieu.monrocq at gmail.com>
wrote:
>
> 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 ?

Off the cuff I don't think there is one & it seems like it might be helpful.

>
> -- Matthieu
>
> [1]: http://stackoverflow.com/a/16076878/147192
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130418/891bb58d/attachment.html>


More information about the cfe-dev mailing list