c37b5ddcc8
The result of COMMON-REF(A&, B&&) where they have no common reference type should not be a reference. The implementation of COMMON-REF fails to check that the result is a reference, so is well-formed when it shouldn't be. This means that common_reference uses that result when it shouldn't. The fix is to reject the result of COMMON-REF(A, B) if it's not a reference, so that common_reference falls through to the next case, which uses COND-RES, which yields a non-reference result. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: PR libstdc++/100894 * include/std/type_traits (__common_ref_impl<X&, Y&>): Only use the type if it's a reference. * testsuite/20_util/common_reference/100894.cc: New test.
10 lines
274 B
C++
10 lines
274 B
C++
// { dg-options "-std=gnu++20" }
|
|
// { dg-do compile { target c++20 } }
|
|
// PR libstdc++/100894 - common_reference implementation seems to be wrong
|
|
|
|
#include <type_traits>
|
|
|
|
struct A {};
|
|
struct B { B(A); };
|
|
static_assert( std::is_same_v<std::common_reference_t<A&, B&&>, B> );
|