http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50025
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-19 20:42:14 UTC --- Jason, I'd like to try and fix this, but need some clues. A minimal example that fails to compile is: struct S { } s; S& r{s}; I find that in call.c:reference_binding we get compatible_p = false, which seems to be wrong. Even if compatible_p is true we don't take the branch that looks like it should be used: /* Directly bind reference when target expression's type is compatible with the reference and expression is an lvalue. In DR391, the wording in [8.5.3/5 dcl.init.ref] is changed to also require direct bindings for const and rvalue references to rvalues of compatible class type. We should also do direct bindings for non-class xvalues. */ if (compatible_p && (is_lvalue || (((CP_TYPE_CONST_NON_VOLATILE_P (to) && !(flags & LOOKUP_NO_RVAL_BIND)) || TYPE_REF_IS_RVALUE (rto)) && (gl_kind || (!(flags & LOOKUP_NO_TEMP_BIND) && (CLASS_TYPE_P (from) || TREE_CODE (from) == ARRAY_TYPE)))))) Naively I would expect compatible_p and is_lvalue to be true for the case above. Does the code earlier in the function need to be adjusted for the case where a braced-init-list has a single element of reference-compatible lvalue type?