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
This commit is contained in:
Paolo Carlini 2015-04-03 17:23:27 +00:00 committed by Paolo Carlini
parent 1dc15b0b9d
commit a3d94329e9
4 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -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

View File

@ -1,3 +1,8 @@
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.

View File

@ -0,0 +1,18 @@
// 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&>());
}