Commit a3d94329 by Paolo Carlini Committed by Paolo Carlini

re PR c++/64085 (ICE on C++14 lambda by-reference capture with an initializer)

/cp
2015-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/64085
	* lambda.c (add_capture): Use dependent_type_p for capture by
	reference too.

/testsuite
2015-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/64085
	* g++.dg/cpp1y/lambda-init13.C: New.

From-SVN: r221858
parent 1dc15b0b
2015-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/64085
* lambda.c (add_capture): Use dependent_type_p for capture by
reference too.
2015-04-02 Marek Polacek <polacek@redhat.com>
PR c++/65642
......
......@@ -506,7 +506,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
if (by_reference_p)
{
type = build_reference_type (type);
if (!real_lvalue_p (initializer))
if (!dependent_type_p (type) && !real_lvalue_p (initializer))
error ("cannot capture %qE by reference", initializer);
}
else
......
2015-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/64085
* g++.dg/cpp1y/lambda-init13.C: New.
2015-04-03 Marek Polacek <polacek@redhat.com>
* g++.dg/cpp0x/pr57101.C: Use proper type for size_t.
......
// PR c++/64085
// { dg-do compile { target c++14 } }
template<typename T>
struct reference_wrapper
{
T& get() const noexcept;
};
template<class T>
auto make_monad(reference_wrapper<T> arg) {
return [&captive = arg.get()](auto&&) { return 1; };
}
int main()
{
make_monad(reference_wrapper<int&>());
}
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