Re: gcc 2.7.2 common subexpression bug with possible kernel imp

Linus Torvalds (torvalds@cs.helsinki.fi)
Fri, 12 Apr 1996 15:24:38 +0300 (EET DST)


>
> This is a classical aliasing situation; you are modifying *p
> indirectly via buf. I think almost every compiler assumes
> "no-pointer-aliasing" when optimizing; otherwise it's very hard to
> optimize.

No, I certainly hope that no compiler makes any such assumption at all: if they
did they couldn't be called C compilers, but maybe "a language almost, but not
exactly C compilers".

The behaviour Tom May sees would _definitely_ be a compiler bug. Gcc has had
those before when it comes to inline assembly. The documentation clearly states
that "memory" in an assembly statement means that the asm statement changes
memory, so if gc optimizes away the test, it's a bug.

There has been talk about extending the C language so that you could tell the
compiler about aliasing stuff, but it's not there yet (and the extensions have
all been cases where you have to _tell_ the compiler that there are no aliases,
not a question of the compiler assuming it regardless of the user)

Linus