From dev-return-6935-apmail-stdcxx-dev-archive=stdcxx.apache.org@stdcxx.apache.org Tue Feb 12 23:17:28 2008 Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 48141 invoked from network); 12 Feb 2008 23:17:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Feb 2008 23:17:28 -0000 Received: (qmail 65282 invoked by uid 500); 12 Feb 2008 23:17:22 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 65261 invoked by uid 500); 12 Feb 2008 23:17:22 -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 65252 invoked by uid 99); 12 Feb 2008 23:17:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Feb 2008 15:17:22 -0800 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 209.85.198.191 as permitted sender) Received: from [209.85.198.191] (HELO rv-out-0910.google.com) (209.85.198.191) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Feb 2008 23:16:50 +0000 Received: by rv-out-0910.google.com with SMTP id k15so3684189rvb.23 for ; Tue, 12 Feb 2008 15:16:58 -0800 (PST) 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=F7TcRuFTMw5kLW4CD6NTRjAAtT+r1LbDcHoHE/VRTgw=; b=LZI3c3cSAVRy6OqR7Pl+6vnL/eMY3bpFan7SKSvoBlZJKhXRsVPMeS0bqPBxP75EHjh14ajHKjdwbK6jfRB4I+tPTo5v+khX9TsPXpUyJfWFJukiCrjAt5z/3+CsdbpKWV6500VEu0Id3Uq0bw5+WejonTuVWxtH4xuqgurHjQ8= 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=iyYJj3bxskjbkYxVnu6iiGSfpwlNSn3uSNJyhQCzgflPLOHmh4/+qWLdIQOAMFHakZV/rihJn3iBR8Y5SITvelTZJPkqNaCqYT+mCgb5bXm8AOxJeuUK+0ndOKfyolo4V3pZFq1GzkWLrg0aU6rgB9dM5y91Arsy049/kHsp5so= Received: by 10.141.33.21 with SMTP id l21mr1378862rvj.140.1202858218497; Tue, 12 Feb 2008 15:16:58 -0800 (PST) Received: from localhost.localdomain ( [71.229.200.170]) by mx.google.com with ESMTPS id b34sm2008525rvf.22.2008.02.12.15.16.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 12 Feb 2008 15:16:57 -0800 (PST) Message-ID: <47B228E7.8090300@roguewave.com> Date: Tue, 12 Feb 2008 16:16:55 -0700 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: dev@stdcxx.apache.org Subject: Re: [PATCH] STDCXX-423 References: 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 Sorry Scott, I still don't understand what you're trying to do here. The problem noted in STDCXX-423 is pretty much theoretical. AFAIK, stdcxx doesn't build or run on any platform with padding bits. In fact, there may not be any such platforms. Which doesn't mean that there will never be any (as pointed out in the comp.lang.c thread I just updated the issue with), just that coming up with a test case will be tough, as will be testing a patch for the problem. Martin Scott Zhong wrote: > --- LIMITS.cpp (revision 624452) > +++ LIMITS.cpp (working copy) > @@ -223,13 +223,27 @@ > return bits; > } > > +template > +unsigned compute_byte_size() > +{ > + T max = T (one); > + unsigned byte = 1; > + for (int i = 1; T (max * two) > max; max *= two, i++) { > + if (i > 8 ) {byte++; i = 1; } > + } > + return byte; > +} > > + > // used to compute the size of a pointer to a member function > struct EmptyStruct { }; > > > // to silence printf() format comaptibility warnings > #define SIZEOF(T) unsigned (sizeof (T)) > + > +// to not include possible bit padding > +#define CALC_SIZEOF(T) compute_byte_size() > > > int main () > @@ -243,17 +257,17 @@ > > #ifndef _RWSTD_NO_BOOL > printf ("#define _RWSTD_BOOL_SIZE %2u /* sizeof (bool) */\n", > - SIZEOF (bool)); > + CALC_SIZEOF (bool)); > #endif // _RWSTD_NO_BOOL > > printf ("#define _RWSTD_CHAR_SIZE %2u /* sizeof (char) */\n", > - SIZEOF (char)); > + CALC_SIZEOF (char)); > printf ("#define _RWSTD_SHRT_SIZE %2u /* sizeof (short) */\n", > - SIZEOF (short)); > + CALC_SIZEOF (short)); > printf ("#define _RWSTD_INT_SIZE %2u /* sizeof (int) */\n", > - SIZEOF (int)); > + CALC_SIZEOF (int)); > printf ("#define _RWSTD_LONG_SIZE %2u /* sizeof (long) */\n", > - SIZEOF (long)); > + CALC_SIZEOF (long)); > > printf ("#define _RWSTD_FLT_SIZE %2u /* sizeof (float) */\n", > SIZEOF (float)); > @@ -319,7 +333,7 @@ > > # define LLong long long > > - printf ("#define _RWSTD_LLONG_SIZE %2u\n", SIZEOF (LLong)); > + printf ("#define _RWSTD_LLONG_SIZE %2u\n", CALC_SIZEOF (LLong)); > > const char llong_name[] = "long long"; > > @@ -332,7 +346,7 @@ > > # define LLong __int64 > > - printf ("#define _RWSTD_LLONG_SIZE %2u\n", SIZEOF (LLong)); > + printf ("#define _RWSTD_LLONG_SIZE %2u\n", CALC_SIZEOF (LLong)); > > const char llong_name[] = "__int64"; > > @@ -352,7 +366,7 @@ > #ifndef _RWSTD_NO_WCHAR_T > > printf ("#define _RWSTD_WCHAR_SIZE %2u /* sizeof (wchar_t) */\n", > - SIZEOF (wchar_t)); > + CALC_SIZEOF (wchar_t)); > > const char *suffix = "U"; > if ((wchar_t)~0 < (wchar_t)0) >