Skip to content

Commit

Permalink
Delete default error constructors (#351)
Browse files Browse the repository at this point in the history
Summary:
As they should have been deleted, since `std::runtime_error` does not provide a default constructor.

Fixes following compilation warnings:
```
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:25:3: warning: explicitly defaulted default constructor is implicitly deleted [-Wdefaulted-function-deleted]
  Exception() = default;
  ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:24:20: note: default constructor of 'Exception' is implicitly deleted because base class 'std::runtime_error' has no default constructor
struct Exception : public std::runtime_error {
                   ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:35:3: warning: explicitly defaulted default constructor is implicitly deleted [-Wdefaulted-function-deleted]
  InvalidOperationException() = default;
  ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:34:36: note: default constructor of 'InvalidOperationException' is implicitly deleted because base class '::gloo::Exception' has a deleted default constructor
struct InvalidOperationException : public ::gloo::Exception {
                                   ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:25:3: note: explicitly defaulted function was implicitly deleted here
  Exception() = default;
  ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:24:20: note: default constructor of 'Exception' is implicitly deleted because base class 'std::runtime_error' has no default constructor
struct Exception : public std::runtime_error {
                   ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:46:3: warning: explicitly defaulted default constructor is implicitly deleted [-Wdefaulted-function-deleted]
  IoException() = default;
  ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:45:22: note: default constructor of 'IoException' is implicitly deleted because base class '::gloo::Exception' has a deleted default constructor
struct IoException : public ::gloo::Exception {
                     ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:25:3: note: explicitly defaulted function was implicitly deleted here
  Exception() = default;
  ^
/Users/malfet/git/pytorch/pytorch/third_party/gloo/gloo/common/error.h:24:20: note: default constructor of 'Exception' is implicitly deleted because base class 'std::runtime_error' has no default constructor
struct Exception : public std::runtime_error {
                   ^
3 warnings generated.
```

Pull Request resolved: #351

Reviewed By: atalman

Differential Revision: D42974916

Pulled By: malfet

fbshipit-source-id: e591a4d75fc31e34c61bdadb7067769b42459254
  • Loading branch information
malfet authored and facebook-github-bot committed Feb 3, 2023
1 parent 1090929 commit 56b221c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gloo/common/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const std::chrono::milliseconds kNoTimeout = std::chrono::milliseconds::zero();

// A base class for all gloo runtime errors
struct Exception : public std::runtime_error {
Exception() = default;
Exception() = delete;
explicit Exception(const std::string& msg) : std::runtime_error(msg) {}
};

Expand All @@ -32,7 +32,7 @@ struct Exception : public std::runtime_error {

// Thrown for invalid operations on gloo APIs
struct InvalidOperationException : public ::gloo::Exception {
InvalidOperationException() = default;
InvalidOperationException() = delete;
explicit InvalidOperationException(const std::string& msg)
: ::gloo::Exception(msg) {}
};
Expand All @@ -43,7 +43,7 @@ struct InvalidOperationException : public ::gloo::Exception {

// Thrown for unrecoverable IO errors
struct IoException : public ::gloo::Exception {
IoException() = default;
IoException() = delete;
explicit IoException(const std::string& msg) : ::gloo::Exception(msg) {}
};

Expand Down

0 comments on commit 56b221c

Please sign in to comment.