[Bug c++/53660] New: function pointer conversion function template with nested-name-specifier ignored

potswa at mac dot com gcc-bugzilla@gcc.gnu.org
Wed Jun 13 19:30:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53660

             Bug #: 53660
           Summary: function pointer conversion function template with
                    nested-name-specifier ignored
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: potswa@mac.com


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) ()’
}

http://stackoverflow.com/questions/11018810

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.



More information about the Gcc-bugs mailing list