comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: HELP ! need to insert value in array !!
Date: 1997/06/29
Date: 1997-06-29T00:00:00+00:00	[thread overview]
Message-ID: <dewar.867589873@merv> (raw)
In-Reply-To: 33b64c2f.43589878@nntp.ix.netcom.com


Michael says

<<Perhaps it was someone who actually knows C.  Whoever said it was
correct.  Objects may be padded in that there may be bytes that are
not used, but there must be no additional padding between array
elements.  For any type T,

        T a;
        T b[5];

we must have sizeof b == 5 * sizeof a. There can be no unused space
between b[0] and b[1].
>>

Ah, a confusion. I thought the statement was about Ada.

But I am interested in how you could construct a valid ANSI C program
with portable semantics that could detect the difference, and in particular
how exactly the ANSI C standard formally prohibits such "additional padding".
This is the sort of requirement that is very easy to state informally, but
much harder to state formally.

What would one expect on a PDP10 with 5 characters per word and an unused
bit left over, or does the ANSI C standard require 36 bits/character on 
this machine?

<<I don't have the C standard at hand, so i would be interested if someone
could quote chapter and verse on this>>

This sort of statement is the kind of statement that Ada would certainly
like to make in the packed case, but it is hard to make it more than
implementation advice.

I also don't see how your conditoin above can be correct

suppose that type T is a struct with a double field and an int field.
The size of this struct would be 12 bytes, but its alignment requirement
is 8, so it would not be possible to laout the array b without alignment
gaps???





  reply	other threads:[~1997-06-29  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <33A9C27C.22F7@post4.tele.dk>
     [not found] ` <5oci49$97g@crl.crl.com>
     [not found]   ` <866920621snz@genesis.demon.co.uk>
1997-06-27  0:00     ` HELP ! need to insert value in array !! Ralph Silverman
1997-06-28  0:00       ` Lawrence Kirby
     [not found]       ` <dewar.867554609@merv>
1997-06-29  0:00         ` Mike Rubenstein
1997-06-29  0:00           ` Robert Dewar [this message]
1997-06-29  0:00             ` Mike Rubenstein
1997-06-29  0:00               ` Robert Dewar
1997-06-29  0:00                 ` Mike Rubenstein
1997-06-30  0:00                 ` Ed Hook
1997-07-04  0:00                 ` Richard A. O'Keefe
1997-07-07  0:00                   ` Clive D.W. Feather
1997-07-01  0:00               ` Al Bowers
1997-07-01  0:00             ` Richard Kenner
1997-07-01  0:00               ` Robert Dewar
1997-07-02  0:00             ` Christian Froeschlin
1997-07-02  0:00               ` Robert Dewar
1997-07-04  0:00             ` Richard A. O'Keefe
1997-07-04  0:00               ` Robert Dewar
1997-07-04  0:00                 ` Mike Rubenstein
1997-07-05  0:00                   ` Robert Dewar
1997-07-05  0:00                     ` Larry Kilgallen
1997-07-05  0:00                     ` Mike Rubenstein
1997-07-05  0:00                       ` Mike Rubenstein
1997-07-10  0:00                     ` Alan Bowler
1997-07-07  0:00                 ` Shmuel (Seymour J.) Metz
1997-07-07  0:00                 ` Mark H. Wood
1997-07-09  0:00                   ` Robert Dewar
1997-07-10  0:00                     ` Lawrence Kirby
1997-07-08  0:00                 ` Richard Kenner
1997-06-30  0:00         ` Samuel T. Harris
replies disabled

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