Bug 56683 - Function types with different language linkages not distinct
Summary: Function types with different language linkages not distinct
Status: RESOLVED DUPLICATE of bug 2316
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2013-03-21 19:30 UTC by Jed Brown
Modified: 2013-03-21 19:42 UTC (History)
0 users

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 Jed Brown 2013-03-21 19:30:51 UTC
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
Comment 1 Andrew Pinski 2013-03-21 19:42:03 UTC
Dup of bug 2316.

*** This bug has been marked as a duplicate of bug 2316 ***