Skip to content

Commit

Permalink
Fix issue #299 GCC 14 warns on use of _.
Browse files Browse the repository at this point in the history
  • Loading branch information
ned14 committed Jun 21, 2024
1 parent f5a45b6 commit 5bcd0f3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 50 deletions.
12 changes: 6 additions & 6 deletions include/outcome/basic_outcome.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,12 @@ SIGNATURE NOT RECOGNISED
swap(this->_ptr, o._ptr);
return;
}
struct _
struct some_type
{
basic_outcome &a, &b;
bool exceptioned{false};
bool all_good{false};
~_()
~some_type()
{
if(!this->all_good)
{
Expand Down Expand Up @@ -1036,11 +1036,11 @@ SIGNATURE NOT RECOGNISED
check(&this->b);
}
}
} _{*this, o};
strong_swap(_.all_good, this->_ptr, o._ptr);
_.exceptioned = true;
} some_type_value{*this, o};
strong_swap(some_type_value.all_good, this->_ptr, o._ptr);
some_type_value.exceptioned = true;
this->_state.swap(o._state);
_.exceptioned = false;
some_type_value.exceptioned = false;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
Expand Down
6 changes: 3 additions & 3 deletions include/outcome/detail/revision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Distributed under the Boost Software License, Version 1.0.
*/

// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
#define OUTCOME_PREVIOUS_COMMIT_REF 9d86631b47fcd1c1aad84511793d8ef1d729a693
#define OUTCOME_PREVIOUS_COMMIT_DATE "2024-06-14 10:51:48 +00:00"
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 9d86631b
#define OUTCOME_PREVIOUS_COMMIT_REF f5a45b6909e732174fe98e59548914bcaa67d847
#define OUTCOME_PREVIOUS_COMMIT_DATE "2024-06-21 11:40:22 +00:00"
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE f5a45b69
74 changes: 33 additions & 41 deletions include/outcome/detail/value_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,11 @@ namespace detail
// Void does nothing
template <> struct move_assign_to_empty<void, false, false>
{
move_assign_to_empty(void *, void *) noexcept
{ /* nothing to assign */
}
move_assign_to_empty(void *, void *) noexcept { /* nothing to assign */ }
};
template <> struct move_assign_to_empty<const void, false, false>
{
move_assign_to_empty(const void *, const void *) noexcept
{ /* nothing to assign */
}
move_assign_to_empty(const void *, const void *) noexcept { /* nothing to assign */ }
};
// Helpers for copy assigning to empty storage
template <class T, bool isCopyConstructible = std::is_copy_constructible<T>::value,
Expand All @@ -92,15 +88,11 @@ namespace detail
// Void does nothing
template <> struct copy_assign_to_empty<void, false, false>
{
copy_assign_to_empty(void *, void *) noexcept
{ /* nothing to assign */
}
copy_assign_to_empty(void *, void *) noexcept { /* nothing to assign */ }
};
template <> struct copy_assign_to_empty<const void, false, false>
{
copy_assign_to_empty(const void *, const void *) noexcept
{ /* nothing to assign */
}
copy_assign_to_empty(const void *, const void *) noexcept { /* nothing to assign */ }
};

template <class T, bool nothrow> struct strong_swap_impl
Expand Down Expand Up @@ -231,9 +223,10 @@ namespace detail
#ifdef _MSC_VER
__declspec(noreturn)
#elif defined(__GNUC__) || defined(__clang__)
__attribute__((noreturn))
__attribute__((noreturn))
#endif
void make_ub(T && /*unused*/)
void
make_ub(T && /*unused*/)
{
OUTCOME_ASSERT(false); // NOLINT
#if defined(__GNUC__) || defined(__clang__)
Expand Down Expand Up @@ -1286,11 +1279,11 @@ namespace detail
// value/value
if(_status.have_value() && o._status.have_value())
{
struct _
struct some_type
{
status_bitfield_type &a, &b;
bool all_good{false};
~_()
~some_type()
{
if(!this->all_good)
{
Expand All @@ -1299,19 +1292,19 @@ namespace detail
this->b.set_have_lost_consistency(true);
}
}
} _{_status, o._status};
strong_swap(_.all_good, _value, o._value);
} some_type_value{_status, o._status};
strong_swap(some_type_value.all_good, _value, o._value);
swap(_status, o._status);
return;
}
// error/error
if(_status.have_error() && o._status.have_error())
{
struct _
struct some_type
{
status_bitfield_type &a, &b;
bool all_good{false};
~_()
~some_type()
{
if(!this->all_good)
{
Expand All @@ -1320,8 +1313,8 @@ namespace detail
this->b.set_have_lost_consistency(true);
}
}
} _{_status, o._status};
strong_swap(_.all_good, _error, o._error);
} some_type_value{_status, o._status};
strong_swap(some_type_value.all_good, _error, o._error);
swap(_status, o._status);
return;
}
Expand Down Expand Up @@ -1371,13 +1364,13 @@ namespace detail
return;
}
// It can now only be value/error, or error/value
struct _
struct some_type
{
status_bitfield_type &a, &b;
_value_type_ *value, *o_value;
_error_type_ *error, *o_error;
bool all_good{true};
~_()
~some_type()
{
if(!this->all_good)
{
Expand All @@ -1386,21 +1379,21 @@ namespace detail
this->b.set_have_lost_consistency(true);
}
}
} _{_status, o._status, OUTCOME_ADDRESS_OF(_value), OUTCOME_ADDRESS_OF(o._value), OUTCOME_ADDRESS_OF(_error), OUTCOME_ADDRESS_OF(o._error)};
} some_type_value{_status, o._status, OUTCOME_ADDRESS_OF(_value), OUTCOME_ADDRESS_OF(o._value), OUTCOME_ADDRESS_OF(_error), OUTCOME_ADDRESS_OF(o._error)};
if(_status.have_value() && o._status.have_error())
{
strong_placement(_.all_good, _.o_value, _.value, [&_] { //
strong_placement(_.all_good, _.error, _.o_error, [&_] { //
swap(_.a, _.b); //
strong_placement(some_type_value.all_good, some_type_value.o_value, some_type_value.value, [&some_type_value] { //
strong_placement(some_type_value.all_good, some_type_value.error, some_type_value.o_error, [&some_type_value] { //
swap(some_type_value.a, some_type_value.b); //
});
});
return;
}
if(_status.have_error() && o._status.have_value())
{
strong_placement(_.all_good, _.o_error, _.error, [&_] { //
strong_placement(_.all_good, _.value, _.o_value, [&_] { //
swap(_.a, _.b); //
strong_placement(some_type_value.all_good, some_type_value.o_error, some_type_value.error, [&some_type_value] { //
strong_placement(some_type_value.all_good, some_type_value.value, some_type_value.o_value, [&some_type_value] { //
swap(some_type_value.a, some_type_value.b); //
});
});
return;
Expand Down Expand Up @@ -1471,12 +1464,12 @@ namespace detail
constexpr
#endif
value_storage_nontrivial_move_assignment &
operator=(value_storage_nontrivial_move_assignment &&o) noexcept(
std::is_nothrow_move_assignable<value_type>::value &&
std::is_nothrow_move_assignable<error_type>::value && noexcept(move_assign_to_empty<value_type>(
static_cast<value_type *>(nullptr),
static_cast<value_type *>(nullptr))) && noexcept(move_assign_to_empty<error_type>(static_cast<error_type *>(nullptr),
static_cast<error_type *>(nullptr)))) // NOLINT
operator=(value_storage_nontrivial_move_assignment &&o) noexcept(std::is_nothrow_move_assignable<value_type>::value &&
std::is_nothrow_move_assignable<error_type>::value &&
noexcept(move_assign_to_empty<value_type>(static_cast<value_type *>(nullptr),
static_cast<value_type *>(nullptr))) &&
noexcept(move_assign_to_empty<error_type>(static_cast<error_type *>(nullptr),
static_cast<error_type *>(nullptr)))) // NOLINT
{
using _value_type_ = typename Base::_value_type_;
using _error_type_ = typename Base::_error_type_;
Expand Down Expand Up @@ -1575,10 +1568,9 @@ namespace detail
#endif
value_storage_nontrivial_copy_assignment &
operator=(const value_storage_nontrivial_copy_assignment &o) noexcept(
std::is_nothrow_copy_assignable<value_type>::value &&
std::is_nothrow_copy_assignable<error_type>::value && noexcept(copy_assign_to_empty<value_type>(
static_cast<value_type *>(nullptr), static_cast<value_type *>(nullptr))) && noexcept(copy_assign_to_empty<error_type>(static_cast<error_type *>(nullptr),
static_cast<error_type *>(nullptr))))
std::is_nothrow_copy_assignable<value_type>::value && std::is_nothrow_copy_assignable<error_type>::value &&
noexcept(copy_assign_to_empty<value_type>(static_cast<value_type *>(nullptr), static_cast<value_type *>(nullptr))) &&
noexcept(copy_assign_to_empty<error_type>(static_cast<error_type *>(nullptr), static_cast<error_type *>(nullptr))))
{
using _value_type_ = typename Base::_value_type_;
using _error_type_ = typename Base::_error_type_;
Expand Down
2 changes: 2 additions & 0 deletions test/tests/issue0291.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Distributed under the Boost Software License, Version 1.0.

#include "quickcpplib/boost/test/unit_test.hpp"

#ifdef __clang__
#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
#endif

namespace
{
Expand Down

0 comments on commit 5bcd0f3

Please sign in to comment.