All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lieven Marchand" <mal@wyrd.be>
To: root@chaos.analogic.com
Cc: Keith Owens <kaos@ocs.com.au>, linux-kernel@vger.kernel.org
Subject: Re: sizeof problem in kernel modules
Date: 24 Jun 2001 18:07:39 +0200	[thread overview]
Message-ID: <m3ae2xn9o4.fsf@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.3.95.1010623224028.22442A-100000@chaos.analogic.com>
In-Reply-To: "Richard B. Johnson"'s message of "Sat, 23 Jun 2001 22:43:14 -0400 (EDT)"

"Richard B. Johnson" <root@chaos.analogic.com> writes:

> On Sun, 24 Jun 2001, Keith Owens wrote:
> 
> > On Sat, 23 Jun 2001 21:56:06 -0400 (EDT), 
> > "Richard B. Johnson" <root@chaos.analogic.com> wrote:
> > >FYI, structures are designed to be accessed only by their member-names.
> > >Therefore, the compiler is free to put members at any offset. In fact,
> > >members, other than the first, don't even have to be in the order
> > >written!
> > 
> > Bzzt!  I don't know where people get these ideas from.  Extracts from
> > the C9X draft.
> > 
> >   A structure type describes a sequentially allocated nonempty set of
> >   member objects (and, in certain circumstances, an incomplete array),
> >   each of which has an optionally specified name and possibly distinct
> >   type.
> > 
> >   When two pointers are compared ... If the objects pointed to are
> >   members of the same aggregate object, pointers to structure members
> >   declared later compare greater than pointers to members declared
> >   earlier in the structure.
> > 
> >   Two objects may be adjacent in memory because they are adjacent
> >   elements of a larger array or adjacent members of a structure with no
> >   padding between them,
> > 
> >   As discussed in 6.2.5, a structure is a type consisting of a sequence
> >   of members, whose storage is allocated in an ordered sequence,
> > 
> >   Within  a structure object, the non-bit-field members and the units
> >   in which bit-fields reside have addresses that increase in the order
> >   in which they are declared
> > 
> > C requires that members of a structure be defined in ascending address
> > order as specified by the programmer.  The compiler may not reorder
> > structure fields, although bitfields are a special case.
> > 
> 
> Previous to the "Draft" "Proposal" of C98, there were no such
> requirements. And so-called ANSI -C specifically declined to
> define any order within structures.

It would be nice it you would occasionally check the stuff you
pontificate about.

The last sentence of the quoted paragraph appears verbatim in the ANSI
X3.159-1989 specification in 3.5.2.1.

-- 
Lieven Marchand <mal@wyrd.be>
You can drag any rat out of the sewer and teach it to get some work done in
Perl, but you cannot teach it serious programming.              Erik Naggum

  reply	other threads:[~2001-06-24 19:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-23 14:54 sizeof problem in kernel modules Der Herr Hofrat
2001-06-23 15:18 ` Keith Owens
2001-06-23 15:30 ` Russell King
2001-06-24  1:56 ` Richard B. Johnson
2001-06-24  2:12   ` Keith Owens
2001-06-24  2:43     ` Richard B. Johnson
2001-06-24 16:07       ` Lieven Marchand [this message]
2001-06-24 16:11       ` frank
2001-06-25  0:26       ` Michael Meissner
2001-06-25 11:32         ` Richard B. Johnson
2001-06-25 13:38           ` Alan Shutko
2001-06-25 13:59             ` Alan Shutko
2001-06-25 15:07               ` Andreas Schwab
2001-06-25 21:25               ` Horst von Brand
2001-06-25 14:49             ` Richard B. Johnson
2001-06-25 19:19               ` Alan Shutko
2001-06-25 20:43           ` Michael Meissner
2001-06-25  4:33 ` Anil Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ae2xn9o4.fsf@localhost.localdomain \
    --to=mal@wyrd.be \
    --cc=kaos@ocs.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=root@chaos.analogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.