| Issue |
60977
|
| Summary |
Deprecated implicit copy ctors/assigns in `libcxx/test`
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
StephanTLavavej
|
MSVC is implementing a new warning (off-by-default) to detect the following deprecated cases (I've heard that Clang and GCC `-Wdeprecated` can also detect this) in [N4928](https://wg21.link/N4928) [\[class.copy.ctor\]/6](https://eel.is/c++draft/class.copy.ctor#6) (emphasis mine):
> 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 defaulted (9.5). **The latter case is deprecated** if the class has a user-declared copy assignment operator or a user-declared destructor (D.8).
and [\[class.copy.assign\]/2](https://eel.is/c++draft/class.copy.assign#2) (emphasis mine):
> If the class definition does not explicitly declare a copy assignment operator, one is declared implicitly. If the class definition declares a move constructor or move assignment operator, the implicitly declared copy assignment operator is defined as deleted; otherwise, it is defaulted (9.5). **The latter case is deprecated** if the class has a user-declared copy constructor or a user-declared destructor (D.8).
While cleaning up MSVC's STL (see https://github.com/microsoft/STL/pull/3497), I found the following deprecated implicit copy ctors/assigns in libcxx's test suite:
* `llvm-project/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp`(29):
+ warning C5267: definition of implicit copy constructor for `'A'` is deprecated because it has a user-provided destructor
+ https://github.com/llvm/llvm-project/blob/53689fdfb29767a12b4d5ad41c67a705a3c622de/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp#L24-L33
* `llvm-project/libcxx/test/support/deleter_types.h`(191):
+ warning C5267: definition of implicit copy constructor for `'CDeleter<A []>'` is deprecated because it has a user-provided destructor
+ https://github.com/llvm/llvm-project/blob/53689fdfb29767a12b4d5ad41c67a705a3c622de/libcxx/test/support/deleter_types.h#L181-L200
* `llvm-project/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp`(29):
+ warning C5267: definition of implicit assignment operator for `'B'` is deprecated because it has a user-provided destructor
+ warning C5267: definition of implicit copy constructor for `'B'` is deprecated because it has a user-provided destructor
+ https://github.com/llvm/llvm-project/blob/53689fdfb29767a12b4d5ad41c67a705a3c622de/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp#L26-L30
@CaseyCarter's https://reviews.llvm.org/D144694 fixes other occurrences in `any` and `optional`'s tests.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs