diff options
author | Marek Polacek <polacek@redhat.com> | 2020-11-03 15:10:31 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2020-11-05 16:34:22 -0500 |
commit | e6fd02cc6d874c523466250a1cb724e0c7af9d75 (patch) | |
tree | 34151764b20973ce61fe02249b2ba515b3cfe2b2 /gcc/gcov-iov.c | |
parent | 1d87302a8e20c1f49dd37177ec869ee94abc11a5 (diff) | |
download | gcc-e6fd02cc6d874c523466250a1cb724e0c7af9d75.zip gcc-e6fd02cc6d874c523466250a1cb724e0c7af9d75.tar.gz gcc-e6fd02cc6d874c523466250a1cb724e0c7af9d75.tar.bz2 |
c++: Fix decltype(auto) deduction with rvalue ref [PR78209]
Here's a small deficiency in decltype(auto). [dcl.type.auto.deduct]/5:
If the placeholder-type-specifier is of the form decltype(auto), [...]
the type deduced for T is determined [...] as though E had been the operand
of the decltype. So:
int &&i = 0;
decltype(auto) j = i; // should behave like int &&j = i; error
We deduce j's type in do_auto_deduction via finish_decltype_type which
takes an 'id' argument. Currently we compute 'id' as false, because
stripped_init is *i (a REFERENCE_REF_P). But it seems to me we should
rather set 'id' to true here, by looking through the REFERENCE_REF_P,
so that finish_decltype_type DTRT.
gcc/cp/ChangeLog:
PR c++/78209
* pt.c (do_auto_deduction): If init is REFERENCE_REF_P, use its
first operand.
gcc/testsuite/ChangeLog:
PR c++/78209
* g++.dg/cpp1y/decltype-auto1.C: New test.
Diffstat (limited to 'gcc/gcov-iov.c')
0 files changed, 0 insertions, 0 deletions