[llvm-bugs] [Bug 45634] New: Missing -Wdeprecated warning when user-declared copy assignment operator is defined as deleted

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 21 15:32:19 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45634

            Bug ID: 45634
           Summary: Missing -Wdeprecated warning when user-declared copy
                    assignment operator is defined as deleted
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

// https://godbolt.org/z/vmKAwd
struct S {
    int i;
    S& operator=(const S&) = delete;
};
S test(const S& s) { return S(s); }

"clang++ -Wdeprecated test.cc" (incorrectly) does not emit a warning for this
code.
It will (correctly) emit a warning if you remove the tokens "= delete" from the
user-provided declaration.

http://eel.is/c++draft/class.copy.ctor#6 :
> If the class definition does not explicitly declare a copy constructor, a non-explicit one is declared implicitly. If the class definition declares a move constructor or move assignment operator, the implicitly declared copy constructor is defined as deleted; otherwise, it is defined as defaulted ([dcl.fct.def]). The latter case is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor ([depr.impldec]).

S's deleted copy assignment operator counts as a user-declared copy assignment
operator; therefore we're in the deprecated case; therefore Clang should warn.

(So says #standardese on Slack, anyway.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200421/1b059edf/attachment.html>


More information about the llvm-bugs mailing list