[Bug c++/56683] New: Function types with different language linkages not distinct

jed at 59A2 dot org gcc-bugzilla@gcc.gnu.org
Thu Mar 21 19:30:00 GMT 2013


             Bug #: 56683
           Summary: Function types with different language linkages not
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jed@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

More information about the Gcc-bugs mailing list