https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01200.html
PR c++/81574
* lambda.c (lambda_capture_field_type): Function references are
always catured by reference.
PR c++/81574
* g++.dg/cpp1y/pr81574.C: New.
From-SVN: r254768
+2017-11-15 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/81574
+ * lambda.c (lambda_capture_field_type): Function references are
+ always catured by reference.
+
2017-11-15 Martin Liska <mliska@suse.cz>
* decl.c (begin_destructor_body): Use cp_build_fold_indirect_ref
{
type = non_reference (unlowered_expr_type (expr));
- if (!is_this && by_reference_p)
+ if (!is_this
+ && (by_reference_p || TREE_CODE (type) == FUNCTION_TYPE))
type = build_reference_type (type);
}
+2017-11-15 Nathan Sidwell <nathan@acm.org>
+
+ PR c++/81574
+ * g++.dg/cpp1y/pr81574.C: New.
+
2017-11-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/82985
--- /dev/null
+// { dg-do compile { target c++14 } }
+// PR c++/81574 references to functions are captured by reference.
+
+// 8.1.5.2/10
+// For each entity captured by copy, ... an lvalue reference to the
+// referenced function type if the entity is a reference to a function
+
+void f (void (&b)())
+{
+ [=] { b; } ();
+ [=, b(f)] { b; } ();
+ [=, b(b)] { b; } ();
+}