public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* std::vector<__m128i> with non-standard allocators
@ 2012-06-11 17:45 Jack Lloyd
  2012-06-11 17:57 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Jack Lloyd @ 2012-06-11 17:45 UTC (permalink / raw)
  To: gcc-help


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-11 19:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-11 17:45 std::vector<__m128i> with non-standard allocators Jack Lloyd
2012-06-11 17:57 ` Jonathan Wakely
2012-06-11 18:50   ` Jack Lloyd
2012-06-11 19:21     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).