Skip to content

Commit

Permalink
Address test failures for C++20 changing traits results (#5164)
Browse files Browse the repository at this point in the history
When C++20 added support for initializing aggregates with parentheses as well
as with braces, there was an unexpected interaction with various type traits
where the formula for determining a trait to be false would now return true
if the result of the implicit array to pointer decay could be stored as the
first element of the array that is the type under test.

A workaround for this scenario is already present in the test driver, but
the preprocessor logic to enable that expected change of test resutls is
overly specific, and does not use the correct feature test macro from the
C++ Standard.

Note that this proposed solution is to retain the old behavior of the bsl
trait, contradicting the value of the standard trait and so raising no
surprises for our existing consumers.  However, as the C++ Standard has
not addressed this issue for C++23 and is not likely to be addressed by
C++26, we might want to consider adopting the complete Standard contract
rather than maintaining our own more sensible result, as the standard
semantics will become expected, and so less surprising for the informed
audience.  For now though, this patch hacks the expected result of the
test driver rather than making bsl conform to a bogus std contract.
  • Loading branch information
AlisdairM authored and GitHub Enterprise committed Feb 5, 2025
1 parent 7af0e46 commit 68d32a2
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions groups/bsl/bslmf/bslmf_isnothrowmoveconstructible.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ void aSsErT(bool condition, const char *message, int line)
// by the `std` trait.

#if defined(BSLMF_ISNOTHROWMOVECONSTRUCTIBLE_USE_NATIVE_ORACLE)
#if defined(BSLS_PLATFORM_CMP_GNU) \
&& BSLS_PLATFORM_CMP_VERSION >= 110000 \
&& BSLS_PLATFORM_CMP_VERSION < 120000 \
&& BSLS_COMPILERFEATURES_CPLUSPLUS == 202002L \
# if defined __cpp_aggregate_paren_init

template <class TYPE>
struct IS_SPECIAL_CASE {
Expand All @@ -200,11 +197,11 @@ struct IS_SPECIAL_CASE {
) };
};

#define ORACLE_VALUE(TYPE) (std::is_nothrow_move_constructible<TYPE>::value \
&& !IS_SPECIAL_CASE<TYPE>::value)
#else
#define ORACLE_VALUE(TYPE) std::is_nothrow_move_constructible<TYPE>::value
#endif
# define ORACLE_VALUE(TYPE) (std::is_nothrow_move_constructible<TYPE>::value \
&& !IS_SPECIAL_CASE<TYPE>::value)
# else
# define ORACLE_VALUE(TYPE) std::is_nothrow_move_constructible<TYPE>::value
# endif
#else
// Cannot use oracle if is not available.
#endif
Expand Down

0 comments on commit 68d32a2

Please sign in to comment.