https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70476

--- Comment #13 from Jiang An <de34 at live dot cn> ---
(In reply to Maciej S. Szmigiero from comment #11)
> (In reply to Andrew Pinski from comment #9)
> > Does these two functions the same name then?
> > ```
> > namespace a {
> >    extern "C" void f(void);
> > }
> > 
> > namespace {
> >   extern "C" void f(void) {}
> > }
> > 
> > void g(void)
> > {
> >   f();
> >   a::f();
> > }
> > 
> > ```
> > It seems counter intuitive that a::f and the ::f map to different functions.
> 
> According to [dcl.link] "Two declarations for a function with C language
> linkage with the same function name (ignoring the namespace names that
> qualify it) that
> appear in different namespace scopes refer to the same function", so it
> would seem that both refer to the same function indeed.
> 
> > Here is an example where GCC produces an assembly failure:
> >
> > namespace a {
> >    extern "C" void f(void){}
> > }
> > 
> > namespace {
> >   extern "C" void f(void) {}
> > }
> 
> If they are the same function then this shouldn't work (it would be a
> re-definition).

Oh, I think they shouldn't be the same function.

[dcl.link]/1 says:
> All functions and variables whose names have external linkage and all
> function types have a language linkage.

which implies that a function with internal linkage doesn't have a language
linkage, and thus [dcl.link]/7 doesn't apply to it.

Reply via email to