Skip to content

Commit 56b221c

Browse files
malfetfacebook-github-bot
authored andcommitted
Delete default error constructors (#351)
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
1 parent 1090929 commit 56b221c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

gloo/common/error.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const std::chrono::milliseconds kNoTimeout = std::chrono::milliseconds::zero();
2222

2323
// A base class for all gloo runtime errors
2424
struct Exception : public std::runtime_error {
25-
Exception() = default;
25+
Exception() = delete;
2626
explicit Exception(const std::string& msg) : std::runtime_error(msg) {}
2727
};
2828

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

3333
// Thrown for invalid operations on gloo APIs
3434
struct InvalidOperationException : public ::gloo::Exception {
35-
InvalidOperationException() = default;
35+
InvalidOperationException() = delete;
3636
explicit InvalidOperationException(const std::string& msg)
3737
: ::gloo::Exception(msg) {}
3838
};
@@ -43,7 +43,7 @@ struct InvalidOperationException : public ::gloo::Exception {
4343

4444
// Thrown for unrecoverable IO errors
4545
struct IoException : public ::gloo::Exception {
46-
IoException() = default;
46+
IoException() = delete;
4747
explicit IoException(const std::string& msg) : ::gloo::Exception(msg) {}
4848
};
4949

0 commit comments

Comments
 (0)