From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,167fc3ed1f7df035 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.202.37 with SMTP id kf5mr2323940pbc.7.1334257094274; Thu, 12 Apr 2012 11:58:14 -0700 (PDT) Path: r9ni48726pbh.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: C's sizeof Date: Thu, 12 Apr 2012 11:58:13 -0700 (PDT) Organization: http://groups.google.com Message-ID: <11092332.346.1334257093663.JavaMail.geo-discussion-forums@ynhh34> References: <10939468.224.1334249018393.JavaMail.geo-discussion-forums@yngq4> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1334257094 8715 127.0.0.1 (12 Apr 2012 18:58:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 12 Apr 2012 18:58:14 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-04-12T11:58:13-07:00 List-Id: On Thursday, April 12, 2012 11:42:46 AM UTC-7, Simon Wright wrote: > Adam Beneschan writes: > > > On Thursday, April 12, 2012 9:27:09 AM UTC-7, Simon Wright wrote: > >> The (draft) ARM Annex B.3[1] says at para 73 - Note 7 - > >> > >> "To obtain the effect of C's sizeof(item_type), where Item_Type is > >> the corresponding Ada type, evaluate the expression: > >> size_t(Item_Type'Size/CHAR_BIT)." > >> > >> Should that not be > >> > >> size_t((Item_Type'Size + CHAR_BIT - 1)/CHAR_BIT) > >> > >> ? > >> > >> [1] http://www.ada-auth.org/standards/12rm/html/RM-B-3.html > > > > Does C even support types whose sizes aren't a multiple of a byte? If > > it doesn't, then since B.3 is talking about the Ada type > > "corresponding" to a C type, the question is probably moot. > > Doesn't B.3 apply to types with Convention => C? > > GNAT allows > > type N2 is range 0 .. Integer'Last - 1; > pragma Convention (C, N2); > > and N2'Size is 31 ... Yeah, you're right. But then I don't think your formula would work either: type N3 is range 0 .. 2**22 - 1; pragma Convention (C, N3); and N3'Size is 22. But what would the sizeof() of the C type be? -- Adam