Skip to content

Commit

Permalink
Workd around a Clang odity, pretending to be GNUC.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adnn committed Apr 24, 2024
1 parent b58c7e9 commit 15a1bb8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/handy/handy/Guard.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class [[nodiscard]] ResourceGuard
/// \brief Release ownership of the resource.
T release()
{
#ifdef __GNUC__
// We only want this for GCC, not clang
// see: https://stackoverflow.com/q/38499462/1027706
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
Expand All @@ -106,7 +108,7 @@ class [[nodiscard]] ResourceGuard
T resource;
std::swap(mResource, resource);
// An alternative would be list-initalization (T resource{}), which would zero-init the builtins.
#ifdef __GNUC__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
mGuard.mReleaser = Guard::turnOff;
Expand Down

0 comments on commit 15a1bb8

Please sign in to comment.