Hi,

When I compile the attached code, I find that one instantiation of vector::_M_fill_insert is double the size of the other even though the semantics should be the same:

$ clang++ -O3 -g -c insert.cpp
$ nm insert.o  --size-sort -Ctd
0000000000000079 W std::vector<A, std::allocator<A> > f<A>()
0000000000000079 W std::vector<long, std::allocator<long> > f<long>()
0000000000001765 W std::vector<long, std::allocator<long> >::_M_fill_insert(__gnu_cxx::__normal_iterator<long*, std::vector<long, std::allocator<long> > >, unsigned long, long const&) 0000000000003638 W std::vector<A, std::allocator<A> >::_M_fill_insert(__gnu_cxx::__normal_iterator<A*, std::vector<A, std::allocator<A> > >, unsigned long, A const&)

What is the reason for this? I would expect that a class trivially containing one member would be treated the same as just the member.

I'm using clang 10 on Ubuntu 20.04.

Best regards,
Marcel

#include <vector>

template<class T>
std::vector<T> f()
{
  std::vector<T> a;
  a.resize(10000, 1);
  return a;
}


class A
{
public:
  long a;
  
  A(long a) : a(a) {}
};

template std::vector<long> f();
template std::vector<A> f();
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to