This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Static linkage and anonymous namespace


> So, we can make it `static' in the C sense.  So, it's fair to warn on:
> 
>   namespace { struct S {}; }
>   void f(vector<S> vs);
> 
> but it's not fair to make that an *error*; it's actually legal, I think.

Why would I even warn on that? If I later get an implementation for f,
fine, if I don't - well, I can't supply one in another translation
unit, so it remains unresolved.

The program

#include <vector>
namespace { struct S {}; }
void f(vector<S> vs)
{
  vs=vs;
}

compiles with my compiler, and I get the following symbols in the
object file on linux-x86 (omitting some):

t __as__t6vector2ZQ215_GLOBAL_.N.a.cc1SZt24__default_alloc_template2b1i0RCt6vector2ZQ215_GLOBAL_.N.a.cc1SZt24__default_alloc_template2b1i0
         U __cp_eh_info
	 ...
t __uninitialized_copy_aux__H2ZPCQ215_GLOBAL_.N.a.cc1SZPQ215_GLOBAL_.N.a.cc1S_X01T0X11G12__false_type_X11
W _t23__malloc_alloc_template1i0.__malloc_alloc_oom_handler
         ...
t f__FGt6vector2ZQ215_GLOBAL_.N.a.cc1SZt24__default_alloc_template2b1i0
	 ...
W lexicographical_compare_3way__H2ZPCScZPCSc_X01T0X11T2_i
W lexicographical_compare__H2ZPCScZPCSc_X01T0X11T2_b

(t here means file-local, W means weak). For template instantiations,
this patch just makes some weak symbols local.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]