[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C99 aliasing rules

From: Ludovic Courtès
Subject: C99 aliasing rules
Date: Mon, 10 Jan 2005 09:55:20 +0100
User-agent: Mutt/1.5.3i


On Fri, Jan 07, 2005 at 08:34:04PM +0100, Marcus Brinkmann wrote:
> Restrict means something completely different: Restrict says that
> pointers to the _same_ type point to non-overlapping storage.  It is
> in this sense stricter than the normal aliasing rule.

Ok, I see.

> Aliasing is defined in the C standard in section 6.5 (#7).  Good luck
> in wrapping your head around the wording of the standard.  It took me
> a couple of days and some research into various usenet discussions,
> and a perusal of the pending defect reports about this issue to
> understand the issues involved and to accept the brutality of the
> aliasing rules.

However, the example you gave:

  typedef union
    _L4_msg_t _msg;
    __L4_msg_tag_t tag;
  } __L4_msg_t;

  _L4_msg_get (_L4_msg_t msg, _L4_word_t *untyped, void *any_typed)
    __L4_msg_t *_msg = (__L4_msg_t *) msg;


should work because _msg's type is an aggregate that includes msg's type
among its members.  Am I missing something?

If this didn't work, this would prevent any similar use of "structure
inheritance", which would be quite unfortunate given that it's widely
used (as in Glib, GTK+, etc.).  If I'm right, it's not _that_ brutal.

> I doubt it's legal - to my knowledge there is no legal downloadable
> copy of ISO C99 on the net.

Right, and that's a pity.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]