Example from StackOverflow (https://stackoverflow.com/q/52662407/2069064): struct Base { }; template<typename T> struct A : Base { A(); A(Base&&); }; A<int> foo() { A<double> v; return v; } gcc accepts this code, invoking the A(Base&&) constructor in the return statement. But the requirement in [class.copy.elision]/3 requires the first type in the selected constructor to be an rvalue reference to the object's type, which it is not.
Smells like a variant of PR 87150 to me, but not a regression as it's been doing the wrong thing since we started treating named lvalues as rvalues in return statements. Marek, could you take a look please?
Happy to.
No longer accepted since r11-2411. The test should probably be added.
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:4f0aa5b051c0d3e81478bcb495e4e072b2d9827d commit r11-3268-g4f0aa5b051c0d3e81478bcb495e4e072b2d9827d Author: Marek Polacek <polacek@redhat.com> Date: Thu Sep 17 15:31:50 2020 -0400 c++: Add tests for fixed PRs. Bugzilla inspection turned up a bunch of old(er) PRs that have been fixed. Let's include them not to regress in the future. gcc/testsuite/ChangeLog: PR c++/87530 PR c++/58156 PR c++/68828 PR c++/86002 PR c++/91525 PR c++/96223 PR c++/87032 PR c++/35098 * g++.dg/cpp0x/move-return4.C: New test. * g++.dg/cpp0x/vt-58156.C: New test. * g++.dg/cpp2a/concepts-pr68828.C: New test. * g++.dg/cpp2a/concepts-pr86002.C: New test. * g++.dg/cpp2a/concepts-pr91525.C: New test. * g++.dg/cpp2a/constexpr-indeterminate1.C: New test. * g++.dg/cpp2a/desig17.C: New test. * g++.dg/ext/attrib62.C: New test.
Fixed.