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

            Bug ID: 60095
           Summary: Dubious diagnostics for attempted surrogate call
                    function
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lucdanton at free dot fr

Using ‘gcc version 4.9.0 20140123 (experimental) (GCC)’ with the following
snippet:

//--------

struct foo {
    typedef void(*ptr)(int&);
    operator ptr() const;
};

int main()
{
    foo f;
    void* p = 0;
    f(p);
}

//--------

$ g++-trunk -std=c++03 main.cpp 
main.cpp: In function 'int main()':
main.cpp:10:8: error: no match for call to '(foo) (void*&)'
     f(p);
        ^
main.cpp:1:8: note: candidate is:
 struct foo {
        ^
main.cpp:10:8: note: foo::ptr {aka void (*)(int&)} <conversion>
     f(p);
        ^
main.cpp:10:8: note:   candidate expects 2 arguments, 2 provided

Same output for all -std=c++{03,11,1y} modes. If e.g. foo has a call operator
instead, then the appropriate ‘no known conversion for argument 1 from 'void*'
to 'int&'’ is produced.

Reply via email to