Related articles |
---|
Re: Why C is much slower than Fortran sokal@holyrood.ed.ac.uk (Daniel Barker) (1999-04-18) |
Re: Why C is much slower than Fortran telken@sgi.com (Thomas Elken) (1999-04-29) |
Re: Why C is much slower than Fortran sokal@holyrood.ed.ac.uk (Daniel Barker) (1999-04-30) |
Re: Why C is much slower than Fortran harley@corton.inria.fr (Robert Harley) (1999-05-03) |
Re: Why C is much slower than Fortran hrubin@stat.purdue.edu (1999-05-09) |
Re: Why C is much slower than Fortran terryg@uswest.net (1999-05-16) |
Re: Why C is much slower than Fortran gneuner@dyn.com (1999-05-16) |
Re: Why C is much slower than Fortran reid@micro.ti.com (Reid Tatge) (1999-05-20) |
Re: Why C is much slower than Fortran jhallen@world.std.com (1999-05-29) |
Re: Why C is much slower than Fortran hwstock@wizard.com (H.W. Stockman) (1999-06-02) |
Re: Why C is much slower than Fortran erik@arbat.com (Erik Corry) (1999-06-02) |
Re: Why C is much slower than Fortran lindahl@pbm.com (1999-06-02) |
[7 later articles] |
From: | terryg@uswest.net (Terry Greyzck) |
Newsgroups: | comp.lang.c++,comp.compilers |
Date: | 16 May 1999 14:11:43 -0400 |
Organization: | Compilers Central |
References: | <3710584B.1C0F05F5@hotmail.com> 99-04-105 99-04-107 99-05-011 99-05-037 |
Keywords: | C, optimize |
hrubin@stat.purdue.edu (Herman Rubin) wrote:
Here's a simple ANSI C routine that illustrates the problem:
int i;
void
pointer_alias( int * const p, const int n )
{
for ( i = 0; i < n; i++ ) {
p[i] = p[i] + 1;
}
}
It looks harmless, but as 'i' is global, the write through 'p' can
change its value, changing the character of the loop. I've actually
seen this type of code appear in 'real' applications.
The new 'restrict' qualifier does help.
-- Terry Greyzck
>Robert Harley <harley@corton.inria.fr> wrote:
>>Our moderator wrote:
>
>>> C lets you alias anything to anything, and that does indeed cause
>>> optimization problems. The C9X draft has a "restrict" keyword [...]
>
>>But ANSI C has a rule which disallows aliasing anything to anything!
>
>>The rule is that an object in memory can only be accessed through
>>lvalues of the same type, possibly in a struct or union, or of char
>>type (here the types are considered modulo signed/unsigned and
>>qualifiers).
terryg@uswest.net
Return to the
comp.compilers page.
Search the
comp.compilers archives again.