Bug 53660 - function pointer conversion function template with nested-name-specifier ignored
Summary: function pointer conversion function template with nested-name-specifier ignored
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2012-06-13 19:30 UTC by David Krauss
Modified: 2012-06-20 11:54 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description David Krauss 2012-06-13 19:30:09 UTC
template< bool >
struct enable_if { typedef void (*t)(); };

struct c {
    template< bool t = true >
    operator typename enable_if< t >::t () { return []{}; }

int main() {
    c()(); // error: no match for call to ‘(c) ()’


In C++03 it seems that it was impossible to define a conversion function template that would render its class Callable. Yet there is a function add_template_conv_candidate (cp/call.c) which seems to be used only for this purpose. It was added back in 1997 and it's not clear that it's been tested in a while. Now with default function template arguments the above construct is possible, and it should be called but isn't.

The problem is that the test for function pointer type (etc.) is applied before instantiation in build_op_call_1. The test probably belongs in add_conv_candidate.