@@ -591,6 +591,7 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain)
{
push_to_top_level ();
push_nested_class (ctx);
+ push_deferring_access_checks (dk_no_deferred);
pushed = true;
}
@@ -616,6 +617,7 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain)
if (pushed)
{
+ pop_deferring_access_checks ();
pop_nested_class ();
pop_from_top_level ();
}
new file mode 100644
@@ -0,0 +1,33 @@
+// PR c++/96673
+// { dg-do compile { target c++11 } }
+
+template <class T>
+class A {};
+
+template <class T>
+class B;
+
+template <class T>
+class C {
+ private:
+
+ friend class B<T>;
+
+ explicit C(A<T>&) {};
+};
+
+
+template <class T>
+class B {
+ public:
+ B() = default;
+ //B() {}; // << This implementation of the constructor makes it work
+
+ A<T> a = {};
+ C<T> c = C<T>{a};
+};
+
+int main() {
+ auto b = B<int>{};
+ auto &c = b.c;
+}