Ian Lance Taylor wrote: > Don't you still have to deal with this case? > > #pragma GCC visibility push(hidden) > template<class T> T f(T); > #pragma GCC visibility pop > ... > #pragma GCC visibility push(default) > extern template int f(int); > #pragma GCC visibility pop > > Personally I wouldn't mind saying that the attribute always beats the > pragma, but it seems to me that there is still the potential for > ambiguity.
I would treat that case as if the template had the attribute, and, therefore, ignore the pragma at the point of instantiation. My concern here is that template instantiation can happen "at any time". I'm sure we all agree that the pragma should affect *implicit* instantiations; if you happened to say: #pragma GCC visibility push(default) int i = f<int>(int); #pragma GCC visibility pop we wouldn't want the visibility of "i" to affect "f<int>". But, an explicit instantiation: template int f<int>(int); should really behave just like an implicit instantiation; it's just a manual way of saying instantiate here. And, "extern template" is a GNU extension which says "there's an explicit instantiation elsewhere; you needn't bother implicitly instantiating here". I'm just not comfortable with the idea of #pragmas affecting instantiations. (I'm OK with them affecting specializations, though; in that case, the original template has basically no impact, so I think it's fine to treat the specialization case as if it were any other function.) -- Mark Mitchell CodeSourcery [EMAIL PROTECTED] (650) 331-3385 x713