commit 5ac81af97e551d65ad46443973d337d388f35297
Author: Jason Merrill <jason@redhat.com>
Date: Mon Mar 25 17:14:04 2013 -0400
PR c++/56699
* semantics.c (maybe_resolve_dummy): Make sure that the enclosing
class is derived from the type of the object.
@@ -9565,7 +9565,8 @@ maybe_resolve_dummy (tree object)
if (type != current_class_type
&& current_class_type
- && LAMBDA_TYPE_P (current_class_type))
+ && LAMBDA_TYPE_P (current_class_type)
+ && DERIVED_FROM_P (type, current_nonlambda_class_type ()))
{
/* In a lambda, need to go through 'this' capture. */
tree lam = CLASSTYPE_LAMBDA_EXPR (current_class_type);
new file mode 100644
@@ -0,0 +1,28 @@
+// PR c++/56699
+// { dg-require-effective-target c++11 }
+
+struct A
+{
+ int a;
+};
+
+struct T
+{
+ int x;
+
+ T() : x([]{
+ sizeof(::A::a);
+ return 0;
+ }())
+ {}
+};
+
+struct B
+{
+ int a;
+};
+
+void f()
+{
+ []{sizeof(B::a);};
+}