On 01/03/2017 08:57 AM, Nathan Sidwell wrote:
else if (!is_this && explicit_init_p) { - type = make_auto (); - type = do_auto_deduction (type, expr, type); + tree auto_node = make_auto (); + + type = auto_node; + if (by_reference_p) + { + /* Add the reference now, so deduction doesn't lose + outermost CV qualifiers of EXPR. */ + type = build_reference_type (type); + by_reference_p = false; + } + type = do_auto_deduction (type, expr, auto_node); } else type = non_reference (unlowered_expr_type (expr)); + + if (!is_this && by_reference_p) + type = build_reference_type (type);
This looks like it will call build_reference_type twice in the explicit init case, producing a reference to reference.
if (DECLTYPE_FOR_LAMBDA_CAPTURE (t)) type = lambda_capture_field_type (type, - DECLTYPE_FOR_INIT_CAPTURE (t)); + DECLTYPE_FOR_INIT_CAPTURE (t), + /*by_reference_p=*/false);
Always passing false seems unlikely to be correct. Jason