Skip to content

Commit

Permalink
Deal with a noexcept issue in ancient libstdc++
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed May 26, 2023
1 parent 51eecd7 commit 2f25a0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion include/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@
#define LIBASSERT_STRONG_EXPECT(expr, value) __builtin_expect((expr), (value))
#endif

// deal with gcc shenanigans
// at one point their std::string's move assignment was not noexcept even in c++17
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
#if defined(_GLIBCXX_USE_CXX11_ABI)
#define GCC_ISNT_STUPID _GLIBCXX_USE_CXX11_ABI
#else
// assume others target new abi by default - homework
#define GCC_ISNT_STUPID 1
#endif

namespace libassert {
enum class ASSERTION {
NONFATAL, FATAL
Expand Down Expand Up @@ -742,7 +752,8 @@ namespace libassert::detail {
binary_diagnostics_descriptor(const binary_diagnostics_descriptor&) = delete;
binary_diagnostics_descriptor(binary_diagnostics_descriptor&&) noexcept; // = default; in the .cpp
binary_diagnostics_descriptor& operator=(const binary_diagnostics_descriptor&) = delete;
binary_diagnostics_descriptor& operator=(binary_diagnostics_descriptor&&) noexcept; // = default; in the .cpp
binary_diagnostics_descriptor&
operator=(binary_diagnostics_descriptor&&) noexcept(GCC_ISNT_STUPID); // = default; in the .cpp
};

void sort_and_dedup(literal_format(&)[format_arr_length]);
Expand Down
2 changes: 1 addition & 1 deletion src/assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ namespace libassert::detail {
LIBASSERT_ATTR_COLD
binary_diagnostics_descriptor::binary_diagnostics_descriptor(binary_diagnostics_descriptor&&) noexcept = default;
LIBASSERT_ATTR_COLD binary_diagnostics_descriptor&
binary_diagnostics_descriptor::operator=(binary_diagnostics_descriptor&&) noexcept = default;
binary_diagnostics_descriptor::operator=(binary_diagnostics_descriptor&&) noexcept(GCC_ISNT_STUPID) = default;

LIBASSERT_ATTR_COLD
static std::string print_values(const std::vector<std::string>& vec, size_t lw) {
Expand Down

0 comments on commit 2f25a0b

Please sign in to comment.