From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18385 invoked by alias); 11 Jun 2012 17:45:08 -0000 Received: (qmail 18185 invoked by uid 22791); 11 Jun 2012 17:45:04 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from chihiro.randombit.net (HELO chihiro.randombit.net) (69.48.226.76) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Jun 2012 17:44:49 +0000 Received: by chihiro.randombit.net (Postfix, from userid 1000) id 4F610124860A; Mon, 11 Jun 2012 13:44:48 -0400 (EDT) Date: Mon, 11 Jun 2012 17:45:00 -0000 From: Jack Lloyd To: gcc-help@gcc.gnu.org Subject: std::vector<__m128i> with non-standard allocators Message-ID: <20120611174448.GM28623@randombit.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-PGP-Fingerprint: 3F69 2E64 6D92 3BBE E7AE 9258 5C0F 96E8 4EC1 6D6B X-PGP-Key: http://www.randombit.net/pgpkey.html User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2012-06/txt/msg00101.txt.bz2 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::__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::__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 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