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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to patrick from comment #0)
> $ g++ -c exc.C
> exc.C:8:26: warning: declaration of ‘void B::foo()’ with C language linkage
> [enabled by default]
>      extern "C" void foo ();
>                           ^
> exc.C:3:21: warning: conflicts with previous declaration ‘void A::foo()’
> [enabled by default]
>      extern "C" void foo () throw ();
>                      ^
> exc.C:8:26: warning: due to different exception specifications [enabled by
> default]
>      extern "C" void foo ();
>                           ^

This inconsistency makes the declaration of B::foo() ill-formed.


> exc.C: In function ‘int main()’:
> exc.C:14:5: error: ‘foo’ is not a member of ‘B’
>      B::foo ();
>      ^

This does not correspond to the code above, I don't know whether the code or
the error is what you mean to post.

In either case, I don't think this is bogus. The function's name is "foo" for
linkage purposes, but as it isn't declared in the global namespace you still
need to qualify it to call it. If you call A::foo() it will compile, or if you
fix the ill-formed redeclaration as B::foo() then you can call it as B::foo().
You cannot call it unqualified though (unless you add a using declaration or
using directive or redeclare it at global scope).

Reply via email to