]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix common_reference for non-reference results [PR100894]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 14 Jun 2021 19:31:00 +0000 (20:31 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 14 Jun 2021 20:17:53 +0000 (21:17 +0100)
commitc37b5ddcc88e0cc0f6a4ad609eda51021df0f6bb
treef038a183eb9ab811e71228d68a8e2ad8bf885cdc
parent4986946f3b761dd4c3e0d79ca735c90e33f4bb83
libstdc++: Fix common_reference for non-reference results [PR100894]

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.
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/common_reference/100894.cc [new file with mode: 0644]