linux-2.3.3 doesn't boot when compiled with egcs-2.93.22
Linus Torvalds
torvalds@transmeta.com
Mon May 31 21:06:00 GMT 1999
In article < 19990524012625R.mitchell@codesourcery.com >,
<mark@codesourcery.com> wrote:
>
>That should work, and may be appropriate for kernel code, which does,
>after all, need to do some low-level grungy stuff. But, you will lose
>some optimization, which is also important in kernels! Perhaps it
>would be a good long-term goal to eliminate this stuff, replacing it
>with assembly where necessary?
Do you _really_ think that it is acceptable to replace something like
this with assembly?
*(unsigned int *)x = *(unsigned int *)y;
That's TWO instructions on most machines. And it's quite obvious what
it is trying to do. Claiming that you should do it in assembly just
because the compiler lacks a way to tell it to screw the alias
information is just ludicrous, imho.
How about gcc instead give some more localized way for the programmer to
say that there are aliases? So that we do not have to compile the whole
kernel with -fno-strict-alias?
For example, anything _cast_ through a (void *) might be considered to
alias with anything else. Document that as a gcc extension to the ANSI
rules, and I think you'll find a lot of people might end up finding that
acceptable. The rule makes more sense than many of the ANSI rules
anyway, and then you'd write the above as
*(unsigned int *)(void *)x = *(unsigned int *)(void *)y;
and you'd be ok. Think of the cast as a "loses all information about
the pointer", and the above not only makes sense from a programmer
perspective, it makes sense from a _conceptual_ viewpoint too.
[ Personal note: I think the ANSI alias standard should just have said
that _any_ pointer cast in any expression always implies that the
resultant access can alias with anything. When you start casting your
pointers, you should lose all type information and thus you should
also lose the "alias class" information. Feel free to disagree, but I
think the current ANSI alias language is just basically obscure and
broken, because it doesn't allow for unaliasing like the above ]
Anyway, sure you can always do your accesses with a "char *", but I
think the "any cast invalidates alias information" rule is simple and
makes sense. And doing accesses a byte at a time is NOT acceptable when
the whole point of aliasing was to speed up programs rather than slow
them down.
Linus
More information about the Gcc-bugs
mailing list