l4-hurd
[Top][All Lists]
Advanced

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

Re: Contribution to the Hurd on L4


From: Marcus Brinkmann
Subject: Re: Contribution to the Hurd on L4
Date: Fri, 07 Jan 2005 20:34:04 +0100
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI)

At Fri, 7 Jan 2005 10:17:07 +0100,
Ludovic Courtès <address@hidden> wrote:
> 
> Hi,
> 
> On Thu, Jan 06, 2005 at 10:46:04PM +0100, Marcus Brinkmann wrote:
> > Ok, the actual rules are complicated, but the basic rule is that two
> > pointers to different types never ever point to overlapping memory
> > regions.  This means that you can't cast pointers to other types and
> > expect them to work.  The compiler can just optimize away derefences
> > to pointers which have the value of a different type.  An exception is
> > char*, which can always be used (otherwise memcpy and friends would
> > not do what you expect).
> 
> My understanding of the standard [1] (section 6.7.3.1) is that what you
> describes holds _only_ for `restrict'-qualified pointers, not for any
> pointer (otherwise most C programs would break when compiled with a C99
> compiler).  The pointers used in the examples you gave did not have this
> qualifier.

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.

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.

> [1] Fortunately, someone had the good idea to keep a copy of the
>     standard on the web: http://www.nirvani.net/docs/ansi_c.pdf .  ;-)

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

Thanks,
Marcus





reply via email to

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