Commit d86d6e27 by Jason Merrill Committed by Jason Merrill

CWG 2267 - list-initialization of reference temporary

	* call.c (reference_binding): List-initializing a reference
	temporary is copy-list-initialization.

From-SVN: r260126
parent 2c9c6ada
2018-05-09 Jason Merrill <jason@redhat.com>
CWG 2267 - list-initialization of reference temporary
* call.c (reference_binding): List-initializing a reference
temporary is copy-list-initialization.
* parser.c (cp_parser_class_head): Use num_template_headers_for_class.
* pt.c (instantiate_decl): Make sure we aren't trying to do a nested
......
......@@ -1560,12 +1560,10 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags,
goto skip;
}
}
/* Otherwise, if T is a reference type, a prvalue temporary of the
type referenced by T is copy-list-initialized or
direct-list-initialized, depending on the kind of initialization
for the reference, and the reference is bound to that temporary. */
conv = implicit_conversion (to, from, expr, c_cast_p,
flags|LOOKUP_NO_TEMP_BIND, complain);
/* Otherwise, if T is a reference type, a prvalue temporary of the type
referenced by T is copy-list-initialized, and the reference is bound
to that temporary. */
CONSTRUCTOR_IS_DIRECT_INIT (expr) = false;
skip:;
}
......
// CWG 2267
// { dg-do compile { target c++11 } }
struct A {} a;
struct B { explicit B(const A&); };
B b1(a); // #1, ok
const B &b2{a}; // { dg-error "" }
const B &b3(a); // { dg-error "" }
struct D { D(); };
struct C { explicit operator D(); } c;
D d1(c); // ok
const D &d2{c}; // { dg-error "" }
const D &d3(c); // { dg-error "" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment