c++/8680: g++ doesn't warn when passing a C++ funcptr instead of extern "C" funcptr

apm35@student.open.ac.uk apm35@student.open.ac.uk
Fri Nov 22 09:30:00 GMT 2002


>Number:         8680
>Category:       c++
>Synopsis:       g++ doesn't warn when passing a C++ funcptr instead of extern "C" funcptr
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 22 09:16:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Andrew Marlow
>Release:        unknown-1.0
>Organization:
>Environment:
Solaris 8, GCC version 3.2
>Description:
extern "C" is now part of functions type in C++. This means that function type matching must take this into account. The attached program has an extern "C" function that takes a function pointer parameter. This should also be treated as a function with extern "C" (see the standard, section 7.5 clause 4) so when a function pointer is passed the compiler should check that it has extern "C" linkage. If it doesn't then at least a warning should be issued. The Solaris Forte 6.2 compiler DOES issue such a warning.
>How-To-Repeat:
Compile the attached file, g++ -c -Wall -pedantic bug.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bug.cpp"
Content-Disposition: inline; filename="bug.cpp"

extern "C" {
void doSomething(int, void*(*)(void*));
};

void* func(void*);

int main()
{
    doSomething(1, func);
    return 0;
}




More information about the Gcc-bugs mailing list