Note: I've already looked here and I don't think the answer is right.
What are the rules governing the implicit instantiation of functions when taking their address? 14.7.1/9 of n3242 says this:
An implementation shall not implicitly instantiate a function template, a member template, a non-virtual member function, a member class, or a static data member of a class template that does not require instantiation.
Now, it's certainly not required to have a function definition in order to take its address. We can take the address of forward-declared functions and have them defined in a different translation unit.
That being the case, I don't know when it would be required. Yet, compilers seem to have their own idea. Testing on GCC and VC, here are a few examples:
template <typename T> void CallBanana() { T::Banana(); }
template <typename T> void CallUnimpl();
template <typename T>
struct S {
static void CallBanana() { T::Banana(); }
static void CallOrange() { T::Orange(); }
static void CallUnimpl();
};
struct B { static void Banana() {} };
int main() {
(void)(&CallBanana<void>); // 1
(void)(&CallUnimpl<void>); // 2
(void)(&S<void>::CallBanana); // 3
(void)(&S<void>::CallOrange); // 4
(void)(&S<void>::CallUnimpl); // 5
(void)(&S<B>::CallBanana); // 6
}
These should be commented-in one at a time to see the effects.
GCC 4.7 tested here will complain about 1, 3, and 4. So it is instantiating all definitions if they exist.
VC 2010 (no online test, sorry) instantiates 3 and 4, yet doesn't instantiate 1.
Clang 3.0 tested here has the same behaviour as VC 2010.
No compiler complains about 2 or 5, which I would expect. I would expect it to fail to link if I actually used those pointers though.
On all compilers, 6 compiles. I expect this, but it is intended to show that the whole class template isn't instantiated (as claimed in the answer to that other question) just because I take the address of a single function. If the whole template was instantiated, then S::CallOrange shouldn't compile, because B doesn't contain an Orange function.
So I'm wondering if anyone has a definitive answer as to what the correct behaviour should be. The standard seems to claim that no functions should be instantiated, yet three popular compilers instantiate in some cases, but differ from each other too.