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

             Bug #: 56683
           Summary: Function types with different language linkages not
                    distinct
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: j...@59a2.org


Section 7.5.1 of C++98 and C++11 states:

    Two function types with different language linkages are
    distinct types even if they are otherwise identical.

If the types are distinct, then surely we can overload on that basis:

    extern "C" typedef int (*CPtr)(void);
    extern "C++" typedef int (*CxxPtr)(void);

    int Klutz(CPtr f) { return f(); }
    int Klutz(CxxPtr f) { return f(); }

This compiles cleanly with Sun and Cray C++ compilers, but not with GCC, Clang,
Intel, MSVC, IBM XL, PathScale, or PGI.

    $ g++ klutz.cc
    klutz.cc: In function ‘int Klutz(CxxPtr)’:
    klutz.cc:5:5: error: redefinition of ‘int Klutz(CxxPtr)’
    klutz.cc:4:5: error: ‘int Klutz(CPtr)’ previously defined here

Reply via email to