Page MenuHomePhabricator

Fix -Wdeprecated-copy-dtor and -Wdeprecated-dynamic-exception-spec warnings.
ClosedPublic

Authored by dim on Mar 13 2020, 11:37 AM.

Details

Summary

The former are like:

libcxx/include/typeinfo:322:11: warning: definition of implicit copy constructor for 'bad_cast' is deprecated because it has a user-declared destructor [-Wdeprecated-copy-dtor]

virtual ~bad_cast() _NOEXCEPT;
        ^

libcxx/include/typeinfo:344:11: note: in implicit copy constructor for 'std::bad_cast' first required here

throw bad_cast();
      ^

Fix these by adding an explicitly defaulted copy constructor.

The latter are like:

libcxx/include/codecvt:105:37: warning: dynamic exception specifications are deprecated [-Wdeprecated-dynamic-exception-spec]

virtual int do_encoding() const throw();
                                ^~~~~~~

Fix these by using the _NOEXCEPT macro instead.

Diff Detail

Event Timeline

dim created this revision.Mar 13 2020, 11:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 13 2020, 11:37 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a subscriber: dexonsmith. · View Herald Transcript
dim added a comment.Mar 13 2020, 11:39 AM

Note: one thing that I am unsure about is the _NOEXCEPT after some of the copy constructors. I only applied those to classes that have other _NOEXCEPT constructors, but copying may involve other things that could throw.

Maybe it is safer to not use _NOEXCEPT at all for all of them, instead?

EricWF accepted this revision.Mar 16 2020, 5:39 PM
In D76150#1922104, @dim wrote:

Note: one thing that I am unsure about is the _NOEXCEPT after some of the copy constructors. I only applied those to classes that have other _NOEXCEPT constructors, but copying may involve other things that could throw.

Maybe it is safer to not use _NOEXCEPT at all for all of them, instead?

I share your concerns. Until very recently Clang diagnosed non-matched exception specifications.
That said, the standard requires these operations not throw so we want to know if the compiler deduces otherwise.

LGTM

This revision is now accepted and ready to land.Mar 16 2020, 5:39 PM
This revision was automatically updated to reflect the committed changes.