From [temp.arg.nontype]:
The template argument for a non-type template parameter must be a constant constant expression (5.20) of the type of the template parameter.
There are two problems here. Firstly, d has no binding, so you cannot refer to it in a constant expression. This is easy to fix, though:
Derived d; int main() { f<d>();
Now we have one more problem. Let's move on to the following sentence:
For a template-template that is not related to the type of the link or the type of the pointer, the value of the constant expression should not be referenced (or for the type of the pointer, there should be no address):
(1.1) is the subobject (1.8),
We are trying to take a link - this is a subobject (subobject of the base class) Derived . This is explicitly prohibited, regardless of binding.
Barry source share