This is essentially CWG issue 1584 :
It is unclear whether the following is correctly formed:
void foo(){} template<class T> void deduce(const T*) { } int main() { deduce(foo); }
Implementations vary in their interpretation of this example.
He is currently active. It is impossible to say which compiler is right. Although, as noted in the 2015 note, the consensus in the WGE now is that this should be rejected.
To give a little more context, we must remember that the type of a function with cv-qualifier-seq has a special meaning (think member functions) and is not just a type that means something that cannot be changed. Moreover, you cannot even add the cv qualification in any hidden manner, since [dcl.fct] / 7 illustrates:
The effect of cv-qualifier-seq in a function declaration is not the same as adding cv-qualifier on top of a function type. c In the latter case, the cv qualifiers are ignored. [Note: the type of function that has cv-qualifier-seq is not a cv-qualified type; No CV-qualified function types. - end note] [Example:
typedef void F(); struct S { const F f;
- end of example]
There is no way in the language to form the type of a const function. And yet, we need to output the output of const T as void() . The first type is of type const, and it must also be functional. But this is the type that cannot exist! So how can this be done ?!
On the other hand, the standard has a mechanism to display it if you used a link instead of a pointer.
So it is not clear how this should be allowed. On the one hand, the wording today does not allow this, but, on the other hand, a mechanism for links already exists for this. Therefore, some implementations go and do the same for pointers.
Storyteller
source share