Skip to content

Commit

Permalink
Fix deprecated behaviour in folly/experimental/exception_tracer/Excep…
Browse files Browse the repository at this point in the history
…tionTracerLib.cpp

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: D54158191

fbshipit-source-id: 185a4f3ddd90601c3f02c3fb6d8ec2e62e8744cb
  • Loading branch information
r-barnes authored and facebook-github-bot committed Feb 26, 2024
1 parent ff3463a commit 6c9ea28
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions folly/experimental/exception_tracer/ExceptionTracerLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ extern "C" {
void __real___cxa_throw(
void* thrownException, std::type_info* type, void (*destructor)(void*))
__attribute__((__noreturn__));
void* __real___cxa_begin_catch(void* excObj) throw();
void* __real___cxa_begin_catch(void* excObj) noexcept;
void __real___cxa_rethrow(void) __attribute__((__noreturn__));
void __real___cxa_end_catch(void);
#else
void __cxa_throw(
void* thrownException, std::type_info* type, void (*destructor)(void*))
__attribute__((__noreturn__));
void* __cxa_begin_catch(void* excObj) throw();
void* __cxa_begin_catch(void* excObj) noexcept;
void __cxa_rethrow(void) __attribute__((__noreturn__));
void __cxa_end_catch(void);
#endif
Expand Down Expand Up @@ -137,7 +137,7 @@ __attribute__((__noreturn__)) void __wrap___cxa_rethrow() {
__builtin_unreachable(); // orig_cxa_rethrow never returns
}

void* __wrap___cxa_begin_catch(void* excObj) throw() {
void* __wrap___cxa_begin_catch(void* excObj) noexcept {
// excObj is a pointer to the unwindHeader in __cxa_exception
getCxaBeginCatchCallbacks().invoke(excObj);
return __real___cxa_begin_catch(excObj);
Expand Down Expand Up @@ -173,7 +173,7 @@ void __cxa_rethrow() {
__builtin_unreachable(); // orig_cxa_rethrow never returns
}

void* __cxa_begin_catch(void* excObj) throw() {
void* __cxa_begin_catch(void* excObj) noexcept {
// excObj is a pointer to the unwindHeader in __cxa_exception
static auto orig_cxa_begin_catch =
reinterpret_cast<decltype(&__cxa_begin_catch)>(
Expand Down

0 comments on commit 6c9ea28

Please sign in to comment.