diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class66.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class66.C
new file mode 100644
index 0000000000000000000000000000000000000000..385b290521fede15462a76239de360d3fd097519
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class66.C
@@ -0,0 +1,19 @@
+// PR c++/109095
+// { dg-do compile { target c++20 } }
+
+template< typename T >
+struct bar
+{};
+
+template< int X >
+struct baz
+{};
+
+template< auto N, template< auto N2 > typename TT >
+struct foo;
+
+template< typename T, bar< T > B, template< T N2 > typename TT >
+struct foo< B, TT >
+{};
+
+foo< bar< int >{}, baz > x;