From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10926 invoked by alias); 11 Jun 2012 19:21:07 -0000 Received: (qmail 10904 invoked by uid 22791); 11 Jun 2012 19:21:05 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-lb0-f175.google.com (HELO mail-lb0-f175.google.com) (209.85.217.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Jun 2012 19:20:41 +0000 Received: by lbol5 with SMTP id l5so3208409lbo.20 for ; Mon, 11 Jun 2012 12:20:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.131.68 with SMTP id ok4mr18093927lab.47.1339442439701; Mon, 11 Jun 2012 12:20:39 -0700 (PDT) Received: by 10.112.48.6 with HTTP; Mon, 11 Jun 2012 12:20:39 -0700 (PDT) In-Reply-To: <20120611185038.GN28623@randombit.net> References: <20120611174448.GM28623@randombit.net> <20120611185038.GN28623@randombit.net> Date: Mon, 11 Jun 2012 19:21:00 -0000 Message-ID: Subject: Re: std::vector<__m128i> with non-standard allocators From: Jonathan Wakely To: Jack Lloyd Cc: gcc-help@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes 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/msg00105.txt.bz2 On 11 June 2012 19:50, Jack Lloyd wrote: > On Mon, Jun 11, 2012 at 06:57:05PM +0100, Jonathan Wakely wrote: > >> The C++ standard says that in a psuedo-destructor call (i.e. an >> expression like p->~U() for a non-class type) the operand shall be a >> scalar type, which would seem to rule out vector types (but then the >> standard says nothing about them anyway.) > > Thanks, I had no realized that the standard allows that for scalar > types. You're not allowed to specialize templates from namespace std for scalar types, but for your_custom_allocator or my_custom_allocator you can specialize anything, or they could just be written to have special handling for scalars without any specialization (e.g. my_custom_allocator::destroy(int*, size_t) could write to std::cout every time it's called.) >> You could either specialize the allocator's destroy function for the >> case of __m128i so it does nothing, or file a bug asking for >> pseudo-destructor calls to be allowed on types like __m128i. > > I considered specialization but that requires me to guess what vector > types someone might want to use (the various AVX, NEON, and AltiVec > types all seem reasonable in the context of the allocator I'm writing) > and additionally pollute the namespace by pulling in headers to find > the definitions, so I was hoping for another approach. > > It's definitely pretty unfortunate that this is rejected in that it > seems (?) like the intent of the pseudo-destructor syntax is to ensure > that p->~U() is always well formed precisely to allow uniform syntax > for cases like this. For scalar types, yes. It's not valid to use a pseudo-destructor call for non-scalar, non-class types e.g. this isn't valid: typedef int array[2]; array a; a.~array(); Vector types like __m128i aren't really part of the C++ type system, so it's not entirely surprising they fall through the gaps between well-defined features and extensions. > I suppose I'll file a bug and hope that people > working on the C++ FE agree this is a reasonable thing to support. It > looks like Clang 3.1 also rejects, Intel C++ 12.1 and Visual C++ 2010 > accepts. Not sure about Comeau as the online compiler doesn't seem to > know about emmintrin.h I think the Comeau online compiler ensures no non-standard headers are usable.