]> gcc.gnu.org Git - 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:34:33 +0000 (21:34 +0100)
commit3ae416e0a77a000b536171dbe06c3c2d136fb8e1
tree7ccf43f6c8d92a3e6d87cc949df669693706decb
parent4f54fb71613724814938d6067a7ec997ea528c9c
libstdc++: Fix common_reference for non-reference results [PR100894]

The result of COMMON-REF(A&, B&&) where they have no common reference
type should be ill-formed. Our implementation fails to check that the
COMMON-REF 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
do.

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 the correct 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.

(cherry picked from commit c37b5ddcc88e0cc0f6a4ad609eda51021df0f6bb)
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/common_reference/100894.cc [new file with mode: 0644]
This page took 0.0556 seconds and 6 git commands to generate.