9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Adriano Verardo <a.verardo@tecmav.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] C compiler question
Date: Tue, 14 Jul 2009 18:26:42 +0200	[thread overview]
Message-ID: <4A5CB1C2.2000805@tecmav.com> (raw)
In-Reply-To: <7144845a3c658a8194be95e64d69486f@coraid.com>

erik quanstrom wrote:
>> The point is how to compute the offset(s) of the last field at compile /
>> run time.
>>
>
> the offset of the last field is not in question.  i believe you mean the size?
>
It's really the same info.

struct
{
      .....     // total sizeof = 100
    int B[..];
}A;

offset(B) = 100,  &(A.B[7]) == address(A) + 100 + 7*sizeof(int).
The compiler accept the dirty but legal expression  A.B[-3]  because it
can compute
the address (or the offset with respect the beginnig of "A") of the B
"-3" cell.

But in this case

struct
{
      .....     // total sizeof = 100
    struct B B;
}A;

with B declared (just named), how 8c could determined the address of A.B.x ?
To accept the above definition of A, say in a global .h, means that every .c
should include the definition of B.
They could be - legally - different, so generating different offsets of
"x" with respect A
in the same program.


>> I prefer to have only the tricky but standard  "char  x[0]" tails.
>>
>
> i'd prefer not to have them, either.  but it's too late for that.
>
>
:-)   And what about

char x[...]  and   x[2] == 2[x]    :-)  :-)
>> Your patch will be included in the next distribution CD ?
>>
>
> no.  i haven't submitted it yet.
>
> - erik
adriano





  reply	other threads:[~2009-07-14 16:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-12  3:59 Adriano Verardo
2009-07-12 16:59 ` erik quanstrom
2009-07-14  2:58   ` Adriano Verardo
2009-07-14  3:14     ` erik quanstrom
2009-07-14 14:00       ` Adriano Verardo
2009-07-14 14:57         ` erik quanstrom
2009-07-14 16:26           ` Adriano Verardo [this message]
2009-07-14 16:38             ` erik quanstrom
2009-07-14 17:18       ` Roman V Shaposhnik
2009-07-14 17:46         ` erik quanstrom
2009-07-14 18:59           ` Roman V Shaposhnik
2009-07-14 19:29             ` erik quanstrom
2009-07-14 19:45               ` Russ Cox
2009-07-15 11:34                 ` Ethan Grammatikidis
2009-07-15 11:38                   ` erik quanstrom
2009-07-14 20:28               ` [9fans] pointers to incomplete types Roman V Shaposhnik
2009-07-15  9:25               ` [9fans] C compiler question robert wilson
2009-07-14  4:00     ` Russ Cox

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=4A5CB1C2.2000805@tecmav.com \
    --to=a.verardo@tecmav.com \
    --cc=9fans@9fans.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).