comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: C's sizeof
Date: Thu, 12 Apr 2012 11:58:13 -0700 (PDT)
Date: 2012-04-12T11:58:13-07:00	[thread overview]
Message-ID: <11092332.346.1334257093663.JavaMail.geo-discussion-forums@ynhh34> (raw)
In-Reply-To: <m2obqwg5ax.fsf@pushface.org>

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



  reply	other threads:[~2012-04-12 18:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-12 16:27 C's sizeof Simon Wright
2012-04-12 16:43 ` Adam Beneschan
2012-04-12 18:42   ` Simon Wright
2012-04-12 18:58     ` Adam Beneschan [this message]
2012-04-12 20:29       ` Simon Wright
2012-04-12 20:59       ` Jeffrey Carter
2012-04-12 22:24 ` Robert A Duff
2012-04-13  5:57   ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox