This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/79533 (C++17 ICE with cast to reference)


The old copy elision code in build_over_call checks to make sure that
we don't hit it for a temporary object in C++17, where it should have
been handled at a higher level.  We were hitting it for this testcase
because the compiler was looking through the cast to reference type to
find the temporary inside, and trying to elide the copy.

I believe that this behavior is (and has been) wrong for all dialects;
in C++14 and below copy elision from a temporary talks about "a
temporary class object _that has not been bound to a reference_", and
the static_cast binds the temporary to a reference.  So this patch
looks through the outermost conversion to reference type, which comes
from binding to the parameter of the copy conversion, but stops at any
earlier conversion to reference type.

Tested x86_64-pc-linux-gnu, applying to trunk.

Attachment: 79533.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]