[cfe-dev] Missing deprecated-copy-dtor warning in Clang-10

Milan Kříž via cfe-dev cfe-dev at lists.llvm.org
Thu Jul 23 00:30:16 PDT 2020


Hi,

I've a question about a clang warning which is fired under -Wdeprecated in older versions of clang (definition 
of implicit copy constructor for 'ITest' is deprecated).

include <utility>

class ITest
{
public:
     virtual ~ITest() = default;
     virtual void testMethod() = 0;
};

class TestImpl : public ITest
{
public:
     virtual void testMethod() override {};
};

int main()
{
     TestImpl impl1;
     TestImpl impl2 = std::move(impl1);
     return 0;
}

Clang versions 5, 6, 7, 8, 9 (and probably earlier) fire the following warning (when using -Wdeprecated):
<source>:6:13: warning: definition of implicit copy constructor for 'ITest' is deprecated because it has a 
user-declared destructor [-Wdeprecated]
     virtual ~ITest() = default;
             ^
<source>:10:7: note: in implicit copy constructor for 'ITest' first required here
class TestImpl : public ITest
       ^
<source>:19:22: note: in implicit move constructor for 'TestImpl' first required here
     TestImpl impl2 = std::move(impl1);

I understand that in standard the definition of implicit copy constructor is really deprecated and even though I 
don't like it, I believe that the warning is correct. However starting with clang-10.0.0, the warning 
disappears. I noticed that there is a new sub-option -Wdeprecated-copy-dtor, but it also doesn't help to get the 
warning. I even tried to add some members to ITest, but the warning doesn't appear anyway. Is it a bug or 
desired behavior?

Thanks,
Mi-L@

-- 
Milan Kříž | Software engineer | Eccam s.r.o. | +420 724 778384 | milan.kriz at eccam.com
Krakovská 9 | Praha 11000 | Czech Republic


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2226 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200723/7aef2e7e/attachment.bin>


More information about the cfe-dev mailing list