std::vector<__m128i> with non-standard allocators

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm having a problem using a custom allocator with a std::vector of
__m128i values, where _Destroy in stl_construct.h will invoke destroy
even on objects with trivial destructors with any allocator other than
std::alloctor. For instance you can see this with

   std::vector<__m128i, __gnu_cxx::new_allocator<__m128i>> v;

which for G++ 4.7.0 (in C++11 mode) produces

In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/x86_64-pc-linux-gnu/bits/c++allocator.h:34:0,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/bits/allocator.h:48,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/vector:62,
                 from vector.cpp:2:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::destroy(_Up*) [with _Up = __vector(2) long long int; _Tp = __vector(2) long long int]':
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/bits/alloc_traits.h:276:4:   required from 'static typename std::enable_if<std::allocator_traits<_Alloc>::__destroy_helper<_Tp>::value, void>::type std::allocator_traits<_Alloc>::_S_destroy(_Alloc&, _Tp*) [with _Tp = __vector(2) long long int; _Alloc = __gnu_cxx::new_allocator<__vector(2) long long int>; typename std::enable_if<std::allocator_traits<_Alloc>::__destroy_helper<_Tp>::value, void>::type = void]'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/bits/alloc_traits.h:399:4:   required from 'static void std::allocator_traits<_Alloc>::destroy(_Alloc&, _Tp*) [with _Tp = __vector(2) long long int; _Alloc = __gnu_cxx::new_allocator<__vector(2) long long int>]'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/bits/stl_construct.h:147:2:   required from 'void std::_Destroy(_ForwardIterator, _ForwardIterator, _Allocator&) [with _ForwardIterator = __vector(2) long long int*; _Allocator = __gnu_cxx::new_allocator<__vector(2) long long int>]'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/bits/stl_vector.h:403:9:   required from 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = __vector(2) long long int; _Alloc = __gnu_cxx::new_allocator<__vector(2) long long int>]'
vector.cpp:8:60:   required from here
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/ext/new_allocator.h:114:29: error: request for member '~__vector(2) long long int' in '* __p', which is of non-class type '__vector(2) long long int'

Interestingly this appears to be due to the fact that for a freestanding

template<typename U> void destroy(U* p) { p->~U(); }

GCC has no issues with

long l;
destroy(&l);

but rejects

__m128i m;
destroy(&m);

with an error like the one above.

Is this behavior intentional/expected?

Please CC me on any replies as I am not on the list.

-Jack


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux