-Wdeprecated-declarations
on members behaves unexpectedly
#55774
Labels
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Issue
A deprecated member variable in a
struct
orclass
makes the entire entity deprecated, even if the user does not actually use the deprecated member (it may even be private). This is behaviour is not mentioned by the C++ reference.In particular, the behaviour differs from MSVC and GCC:
Expected behaviour
The deprecation warning is raised only when the member variable is actually used by the user.
The difference in behaviour between Clang and MSVC is removed.
Alternative solution
Report bug to MSVC to remove the difference between Clang and MSVC.
Minimal example
A full minimal example can be found in this godbolt example. The code is also below. Note in particular, the implicit move constructor.
Class
Note that the above also happens for otherwise fully private members in
classes
.Non-triggering edge case
Note that if no (implicit)
move
constructor is used, the warning is not raised:Class
Note that the above bug also happens for otherwise fully private members in
classes
:The text was updated successfully, but these errors were encountered: