Why is the deprecated copy warning suppressed in MSVC compatibility mode?

Hi,

comparing diagnostics behavior between clang on Linux and clang on Windows in MSVC compat mode, I noticed that the deprecated copy warning (enabled via -Wdeprecated-copy) is not raised in the latter case.
Judging by this comment in clang’s source, this is a deliberate choice, though I do not fully understand the reasoning behind it.
Can anyone shed some light here? :slight_smile:

Thanks,
Julius

Good question! We hit a bug in Chromium a while ago which I think this warning would catch on Windows.

I don’t understand the comment in the code. Perhaps we should try removing the special casing for Windows and see if it breaks something?

It seems to come from here: :gear: D26868 Sema: As of MSVC 2015, a user-declared move operation causes the deletion of both copy operations. (llvm.org)

But maybe it’s no longer true in newer versions of MSVC?

I think it’s from the warning was originally added: C++11: If a class has a user-declared copy operation or destructor, the · llvm/llvm-project@d577fbb · GitHub

I found the following SemaCXX test cases dealing with the deprecated copy warning (though the list may be incomplete):

None of these seem to cover the MSVC specific behavior.

I also did not find any reference to the deprecated copy warning in the compatibility related test cases (MicrosoftCompatibility.cpp), though the quirks mentioned by @tobiashieta seem to be covered there.

I submitted a patch that causes the deprecated copy warning to be also raised in MSVC compatibility mode:
https://reviews.llvm.org/D133354