Sequence of C++ PATCHes to C++11 reference semantics

Jason Merrill jason@redhat.com
Mon Sep 12 19:27:00 GMT 2011


While debugging a template deduction change that I didn't end up making, 
I fell down a rabbit hole into issues with our handling of C++11 
reference semantics.  Most of these changes are less necessary without 
the deduction change, but there is still a minor bug fix here, and I've 
been meaning to clean up this stuff for a while now.

1) reference_binding wasn't handling xvalues (what you get from e.g. a 
function returning an rvalue reference) properly.  I fixed 
LOOKUP_NO_TEMP_BIND to not apply to xvalues, and fixed rvalue reference 
binding to respect it.  Then I realized that the rules for ?: 
conversions are stricter, requiring actual lvalue/lvalue match rather 
than just direct binding, so I had to add LOOKUP_NO_RVAL_BIND as well.

2) For some reason we weren't passing the LOOKUP flags down through the 
reference binding functions.  This change isn't necessary without the 
deduction change, but seems correct.

3) We had two separate functions doing the same thing: 
build_user_type_conversion_1 and convert_class_to_reference_1.  This led 
to bugs from changes being made in one place and not the other.  I've 
fixed this by discarding the reference-specific function.  This change 
required change #1 above.

4) As a result of #3 we started rejecting explicit conversion functions 
that would require a further conversion of greater than exact match rank 
to the reference type being initialized.  This seems correct to me even 
though the standard doesn't say that yet.  I had to change some things 
around a bit to get a helpful error message for this case.

Tested x86_64-pc-linux-gnu, applying to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ref-overhaul.patch
Type: text/x-patch
Size: 23588 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110912/13b9a593/attachment.bin>


More information about the Gcc-patches mailing list