Skip to content

Commit 5bcd0f3

Browse files
committed
Fix issue #299 GCC 14 warns on use of _.
1 parent f5a45b6 commit 5bcd0f3

File tree

4 files changed

+44
-50
lines changed

4 files changed

+44
-50
lines changed

include/outcome/basic_outcome.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -989,12 +989,12 @@ SIGNATURE NOT RECOGNISED
989989
swap(this->_ptr, o._ptr);
990990
return;
991991
}
992-
struct _
992+
struct some_type
993993
{
994994
basic_outcome &a, &b;
995995
bool exceptioned{false};
996996
bool all_good{false};
997-
~_()
997+
~some_type()
998998
{
999999
if(!this->all_good)
10001000
{
@@ -1036,11 +1036,11 @@ SIGNATURE NOT RECOGNISED
10361036
check(&this->b);
10371037
}
10381038
}
1039-
} _{*this, o};
1040-
strong_swap(_.all_good, this->_ptr, o._ptr);
1041-
_.exceptioned = true;
1039+
} some_type_value{*this, o};
1040+
strong_swap(some_type_value.all_good, this->_ptr, o._ptr);
1041+
some_type_value.exceptioned = true;
10421042
this->_state.swap(o._state);
1043-
_.exceptioned = false;
1043+
some_type_value.exceptioned = false;
10441044
#ifdef _MSC_VER
10451045
#pragma warning(pop)
10461046
#endif

include/outcome/detail/revision.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ Distributed under the Boost Software License, Version 1.0.
2222
*/
2323

2424
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
25-
#define OUTCOME_PREVIOUS_COMMIT_REF 9d86631b47fcd1c1aad84511793d8ef1d729a693
26-
#define OUTCOME_PREVIOUS_COMMIT_DATE "2024-06-14 10:51:48 +00:00"
27-
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 9d86631b
25+
#define OUTCOME_PREVIOUS_COMMIT_REF f5a45b6909e732174fe98e59548914bcaa67d847
26+
#define OUTCOME_PREVIOUS_COMMIT_DATE "2024-06-21 11:40:22 +00:00"
27+
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE f5a45b69

include/outcome/detail/value_storage.hpp

+33-41
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,11 @@ namespace detail
5757
// Void does nothing
5858
template <> struct move_assign_to_empty<void, false, false>
5959
{
60-
move_assign_to_empty(void *, void *) noexcept
61-
{ /* nothing to assign */
62-
}
60+
move_assign_to_empty(void *, void *) noexcept { /* nothing to assign */ }
6361
};
6462
template <> struct move_assign_to_empty<const void, false, false>
6563
{
66-
move_assign_to_empty(const void *, const void *) noexcept
67-
{ /* nothing to assign */
68-
}
64+
move_assign_to_empty(const void *, const void *) noexcept { /* nothing to assign */ }
6965
};
7066
// Helpers for copy assigning to empty storage
7167
template <class T, bool isCopyConstructible = std::is_copy_constructible<T>::value,
@@ -92,15 +88,11 @@ namespace detail
9288
// Void does nothing
9389
template <> struct copy_assign_to_empty<void, false, false>
9490
{
95-
copy_assign_to_empty(void *, void *) noexcept
96-
{ /* nothing to assign */
97-
}
91+
copy_assign_to_empty(void *, void *) noexcept { /* nothing to assign */ }
9892
};
9993
template <> struct copy_assign_to_empty<const void, false, false>
10094
{
101-
copy_assign_to_empty(const void *, const void *) noexcept
102-
{ /* nothing to assign */
103-
}
95+
copy_assign_to_empty(const void *, const void *) noexcept { /* nothing to assign */ }
10496
};
10597

10698
template <class T, bool nothrow> struct strong_swap_impl
@@ -231,9 +223,10 @@ namespace detail
231223
#ifdef _MSC_VER
232224
__declspec(noreturn)
233225
#elif defined(__GNUC__) || defined(__clang__)
234-
__attribute__((noreturn))
226+
__attribute__((noreturn))
235227
#endif
236-
void make_ub(T && /*unused*/)
228+
void
229+
make_ub(T && /*unused*/)
237230
{
238231
OUTCOME_ASSERT(false); // NOLINT
239232
#if defined(__GNUC__) || defined(__clang__)
@@ -1286,11 +1279,11 @@ namespace detail
12861279
// value/value
12871280
if(_status.have_value() && o._status.have_value())
12881281
{
1289-
struct _
1282+
struct some_type
12901283
{
12911284
status_bitfield_type &a, &b;
12921285
bool all_good{false};
1293-
~_()
1286+
~some_type()
12941287
{
12951288
if(!this->all_good)
12961289
{
@@ -1299,19 +1292,19 @@ namespace detail
12991292
this->b.set_have_lost_consistency(true);
13001293
}
13011294
}
1302-
} _{_status, o._status};
1303-
strong_swap(_.all_good, _value, o._value);
1295+
} some_type_value{_status, o._status};
1296+
strong_swap(some_type_value.all_good, _value, o._value);
13041297
swap(_status, o._status);
13051298
return;
13061299
}
13071300
// error/error
13081301
if(_status.have_error() && o._status.have_error())
13091302
{
1310-
struct _
1303+
struct some_type
13111304
{
13121305
status_bitfield_type &a, &b;
13131306
bool all_good{false};
1314-
~_()
1307+
~some_type()
13151308
{
13161309
if(!this->all_good)
13171310
{
@@ -1320,8 +1313,8 @@ namespace detail
13201313
this->b.set_have_lost_consistency(true);
13211314
}
13221315
}
1323-
} _{_status, o._status};
1324-
strong_swap(_.all_good, _error, o._error);
1316+
} some_type_value{_status, o._status};
1317+
strong_swap(some_type_value.all_good, _error, o._error);
13251318
swap(_status, o._status);
13261319
return;
13271320
}
@@ -1371,13 +1364,13 @@ namespace detail
13711364
return;
13721365
}
13731366
// It can now only be value/error, or error/value
1374-
struct _
1367+
struct some_type
13751368
{
13761369
status_bitfield_type &a, &b;
13771370
_value_type_ *value, *o_value;
13781371
_error_type_ *error, *o_error;
13791372
bool all_good{true};
1380-
~_()
1373+
~some_type()
13811374
{
13821375
if(!this->all_good)
13831376
{
@@ -1386,21 +1379,21 @@ namespace detail
13861379
this->b.set_have_lost_consistency(true);
13871380
}
13881381
}
1389-
} _{_status, o._status, OUTCOME_ADDRESS_OF(_value), OUTCOME_ADDRESS_OF(o._value), OUTCOME_ADDRESS_OF(_error), OUTCOME_ADDRESS_OF(o._error)};
1382+
} some_type_value{_status, o._status, OUTCOME_ADDRESS_OF(_value), OUTCOME_ADDRESS_OF(o._value), OUTCOME_ADDRESS_OF(_error), OUTCOME_ADDRESS_OF(o._error)};
13901383
if(_status.have_value() && o._status.have_error())
13911384
{
1392-
strong_placement(_.all_good, _.o_value, _.value, [&_] { //
1393-
strong_placement(_.all_good, _.error, _.o_error, [&_] { //
1394-
swap(_.a, _.b); //
1385+
strong_placement(some_type_value.all_good, some_type_value.o_value, some_type_value.value, [&some_type_value] { //
1386+
strong_placement(some_type_value.all_good, some_type_value.error, some_type_value.o_error, [&some_type_value] { //
1387+
swap(some_type_value.a, some_type_value.b); //
13951388
});
13961389
});
13971390
return;
13981391
}
13991392
if(_status.have_error() && o._status.have_value())
14001393
{
1401-
strong_placement(_.all_good, _.o_error, _.error, [&_] { //
1402-
strong_placement(_.all_good, _.value, _.o_value, [&_] { //
1403-
swap(_.a, _.b); //
1394+
strong_placement(some_type_value.all_good, some_type_value.o_error, some_type_value.error, [&some_type_value] { //
1395+
strong_placement(some_type_value.all_good, some_type_value.value, some_type_value.o_value, [&some_type_value] { //
1396+
swap(some_type_value.a, some_type_value.b); //
14041397
});
14051398
});
14061399
return;
@@ -1471,12 +1464,12 @@ namespace detail
14711464
constexpr
14721465
#endif
14731466
value_storage_nontrivial_move_assignment &
1474-
operator=(value_storage_nontrivial_move_assignment &&o) noexcept(
1475-
std::is_nothrow_move_assignable<value_type>::value &&
1476-
std::is_nothrow_move_assignable<error_type>::value && noexcept(move_assign_to_empty<value_type>(
1477-
static_cast<value_type *>(nullptr),
1478-
static_cast<value_type *>(nullptr))) && noexcept(move_assign_to_empty<error_type>(static_cast<error_type *>(nullptr),
1479-
static_cast<error_type *>(nullptr)))) // NOLINT
1467+
operator=(value_storage_nontrivial_move_assignment &&o) noexcept(std::is_nothrow_move_assignable<value_type>::value &&
1468+
std::is_nothrow_move_assignable<error_type>::value &&
1469+
noexcept(move_assign_to_empty<value_type>(static_cast<value_type *>(nullptr),
1470+
static_cast<value_type *>(nullptr))) &&
1471+
noexcept(move_assign_to_empty<error_type>(static_cast<error_type *>(nullptr),
1472+
static_cast<error_type *>(nullptr)))) // NOLINT
14801473
{
14811474
using _value_type_ = typename Base::_value_type_;
14821475
using _error_type_ = typename Base::_error_type_;
@@ -1575,10 +1568,9 @@ namespace detail
15751568
#endif
15761569
value_storage_nontrivial_copy_assignment &
15771570
operator=(const value_storage_nontrivial_copy_assignment &o) noexcept(
1578-
std::is_nothrow_copy_assignable<value_type>::value &&
1579-
std::is_nothrow_copy_assignable<error_type>::value && noexcept(copy_assign_to_empty<value_type>(
1580-
static_cast<value_type *>(nullptr), static_cast<value_type *>(nullptr))) && noexcept(copy_assign_to_empty<error_type>(static_cast<error_type *>(nullptr),
1581-
static_cast<error_type *>(nullptr))))
1571+
std::is_nothrow_copy_assignable<value_type>::value && std::is_nothrow_copy_assignable<error_type>::value &&
1572+
noexcept(copy_assign_to_empty<value_type>(static_cast<value_type *>(nullptr), static_cast<value_type *>(nullptr))) &&
1573+
noexcept(copy_assign_to_empty<error_type>(static_cast<error_type *>(nullptr), static_cast<error_type *>(nullptr))))
15821574
{
15831575
using _value_type_ = typename Base::_value_type_;
15841576
using _error_type_ = typename Base::_error_type_;

test/tests/issue0291.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ Distributed under the Boost Software License, Version 1.0.
2525

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

28+
#ifdef __clang__
2829
#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
30+
#endif
2931

3032
namespace
3133
{

0 commit comments

Comments
 (0)