Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 78109 invoked from network); 26 Jun 2008 16:04:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jun 2008 16:04:30 -0000 Received: (qmail 43938 invoked by uid 500); 26 Jun 2008 16:04:31 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 43925 invoked by uid 500); 26 Jun 2008 16:04:31 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 43910 invoked by uid 99); 26 Jun 2008 16:04:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 09:04:31 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msebor@gmail.com designates 64.233.184.226 as permitted sender) Received: from [64.233.184.226] (HELO wr-out-0506.google.com) (64.233.184.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 16:03:38 +0000 Received: by wr-out-0506.google.com with SMTP id c8so47913wra.27 for ; Thu, 26 Jun 2008 09:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :organization:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding:sender; bh=frdn9pigUJOd8+27ZRcG3/ZsxpEygitHOgY3S8bY3CU=; b=eZAq3um7viCYnkyikmHepquZGD5m8S5e1EiiPIGc7W6vvFpuWC8eSyH8J/BVg023ye jNJvq6I3swbz4cEacYwmrl3CBE8fIzHsxJ2eVHlSz06aA6ScTTVZguasBYH4cPHyf35C PUlj/zZjvmlg2Rcdq9BQg2bKMmnjq/cUQH9g4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:organization:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding:sender; b=VPwRCRQzW7sQAoboNxff3tjQkoo3tf4PNr+IE17zGdrIvHaYfR8nl4C8OQ0u9jn4bW uzqvfHp0csqMZ0TFImovgSkteoq41nobQtOOMB50AmxZzz+PpbvydPDVLkYKHPUL3NRk M2vRdrE0AG40Bteji/n4cV3V0jT0jYSUAXnP0= Received: by 10.90.78.10 with SMTP id a10mr41599agb.108.1214496237670; Thu, 26 Jun 2008 09:03:57 -0700 (PDT) Received: from localhost.localdomain ( [71.229.200.170]) by mx.google.com with ESMTPS id 23sm241132hsd.10.2008.06.26.09.03.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 26 Jun 2008 09:03:56 -0700 (PDT) Message-ID: <4863BDEB.1090606@roguewave.com> Date: Thu, 26 Jun 2008 10:03:55 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Thunderbird 2.0.0.14 (X11/20080501) MIME-Version: 1.0 To: dev@stdcxx.apache.org Subject: Re: question about aligned_storage References: <48618975.7070800@roguewave.com> <4861BCF0.30108@roguewave.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Martin Sebor X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: > > > Martin Sebor wrote: [...] >> I'm probably missing something but is aligned_storage only specified >> for alignment of powers of 2? (It looks to me as though those are the >> only alignments we support.) > > Yes. I probably need to do something here, but I'm not sure what. Table > 51 says > > _Align shall be equal to alignment_of::value for some type > T or to `default-alignment' > > This essentially says that I need to support all valid alignment values > on the platform. Fortunately, for the time being the power of two > restriction is okay. The only functionality I have available to me for > doing alignment (on the tested platforms) is __declspec(align(#)) on > Microsoft and __attribute__ ((aligned(#))) on gcc-4.3. Both of these > support functions require that the alignment value be a power of two. > The Microsoft compiler has the 8192 limit. An upper limit is acceptable (it should be mentioned in one of the appendices to the spec). I'm more interested in alignments that aren't powers of 2. It's not clear to me why restricting the template to powers of 2 is okay or why it's difficult not to support all of them up to the limit. > > The draft shows a 'typical implementation' of aligned_storage that uses > the new alignas keyword, but alignas doesn't appear to be supported > anywhere. That's probably because they didn't want to favor any existing implementation over others. > The following code is very similar to that typical > implementation, but it does not compile because value passed to the > aligned attribute has to be a literal, not a constant expression. That's what you for using a crappy compiler ;-) It compiles with gcc. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19163 but watch out for: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36625 We should open an enhancement request with Microsoft. Martin > > template std::size_t _Align = __rw_default_alignment<_Size>::value> > struct __rw_aligned_storage > { > typedef struct { > char _C_align [_Size] __attribute__ ((aligned(_Align))); > } type; > }; > > Travis > >> Martin >> >>>> See http://tinyurl.com/5kmvdy for reference. >>>> >>>> Martin >>>> >>>> >>