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

--- Comment #7 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 
2011-11-07 09:23:30 UTC ---
The situation now is even more confused.
Most of the std algos have iterators as arguments. Visibility seems not to
propagate there..

below is my extensive test

compile as
c++ -O0 -shared -fPIC -fvisibility=hidden -o bha.so testICF.cpp 
nm bha.so | c++filt
and look at the mixture of " t " and " T "
for instance
000000000000ad7f t void std::__adjust_heap<__gnu_cxx::__normal_iterator<C**,
std::vector<C*, std::allocator<C*> > >, long,
C*>(__gnu_cxx::__normal_iterator<C**, std::vector<C*, std::allocator<C*> > >,
long, long, C*)
000000000000afea T void
std::__iter_swap<true>::iter_swap<__gnu_cxx::__normal_iterator<C**,
std::vector<C*, std::allocator<C*> > >, __gnu_cxx::__normal_iterator<C**,
std::vector<C*, std::allocator<C*>
etc

cat testICF.cpp
#include<vector>
#include<algorithm>
#include<cmath>

struct A {
 A(float q=0): v(q){} 
 float v;
 bool operator<(A const & a) const { return v<a.v;}
};

struct B { 
 B(float q=0): v(q){}
 bool operator<(B const & a) const { return v<a.v;}

 float v;

};


struct C {
 C(double q=0): v(q){}
 bool operator<(C const & a) const { return v<a.v;}

 double v;

};



float cosq(A const & a) {
   return cos(a.v);
}
float cosq(B const & a) {
   return cos(a.v);
}



template<typename T> 
int game(std::vector<T> const & a, std::vector<T> & b) {
   typedef typename std::vector<T>::const_iterator Iter;
   for (Iter i=a.begin(); i!=a.end(); ++i) {
    if ( (*i).v>0.) b.push_back((*i).v+1);
   }
   std::sort(b.begin(),b.end());
   return b.size();
}

template<typename T> 
int gamep(std::vector<T*> const & a, std::vector<T*> & b) {
   typedef typename std::vector<T*>::const_iterator Iter;
   for (Iter i=a.begin(); i!=a.end(); ++i) {
        if ( (*i)->v>0.) b.push_back((*i));
   }
   std::sort(b.begin(),b.end());
   return b.size();
}

namespace data /* __attribute__((visibility("default"))) */ {

std::vector<A> a; 
std::vector<B> b;
std::vector<C> c;

std::vector<A*> ap;
std::vector<B*> bp;
std::vector<C*> cp;

}

#include<iostream>
int __attribute__((visibility("default"))) go() {
  using namespace data;
  int ret=0;    
try {
  ret+=game(a,a);
  ret+=game(b,b);
  ret+=game(c,c);

  ret+=gamep(ap,ap);
  ret+=gamep(bp,bp);
  ret+=gamep(cp,cp);
} catch (std::exception & ce) {
  std::cout << ce.what() << std::endl;
}

  return ret;

}

Reply via email to