Skip to content

Commit

Permalink
Fix deprecated behaviour in folly/Subprocess.h
Browse files Browse the repository at this point in the history
Summary:
Future C++ standards and compiler upgrades will eliminate deprecated behaviour. `-Wdeprecated` identifies this behaviour and has found some in this code!

Some examples.

**Dynamic exceptions**
```
error: dynamic exception specifications are deprecated [-Werror,-Wdeprecated-dynamic-exception-spec]
```
`throw(...)` has been deprecated since C++11 and removed in C++17. In most cases we can just use `noexcept` in the rest, we can remove this.

**Implicit copy constructors**
```
error: definition of implicit copy constructor for 'XXX' is deprecated because it has a user-declared destructor [-Werror,-Wdeprecated-copy-with-dtor]
```
If you define a destructor, you need to explicitly define a copy constructor.

**Out-ofline constexpr static**
```
error: out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated [-Werror,-Wdeprecated]
```
This can be simplified:
```
class MyClass {
    static constexpr my_const = 3;
};

static constexpr MyClass::my_const; // <- No longer needed!
```

Reviewed By: meyering

Differential Revision: D54158200

fbshipit-source-id: 48d316b567810ddf8547038232eeef97b4054f61
  • Loading branch information
r-barnes authored and facebook-github-bot committed Feb 26, 2024
1 parent 6c9ea28 commit 4c624e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions folly/Subprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class FOLLY_EXPORT SubprocessError : public std::runtime_error {
class FOLLY_EXPORT CalledProcessError : public SubprocessError {
public:
explicit CalledProcessError(ProcessReturnCode rc);
~CalledProcessError() throw() override = default;
~CalledProcessError() noexcept override = default;
ProcessReturnCode returnCode() const { return returnCode_; }

private:
Expand All @@ -250,7 +250,7 @@ class FOLLY_EXPORT CalledProcessError : public SubprocessError {
class FOLLY_EXPORT SubprocessSpawnError : public SubprocessError {
public:
SubprocessSpawnError(const char* executable, int errCode, int errnoValue);
~SubprocessSpawnError() throw() override = default;
~SubprocessSpawnError() noexcept override = default;
int errnoValue() const { return errnoValue_; }

private:
Expand Down

0 comments on commit 4c624e2

Please sign in to comment.