This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] C undefined behavior fix


On Sat, Jan 05, 2002 at 11:17:52AM -0800, Linus Torvalds wrote:
> Can you limit it down enough to be useful, then?

What do you mean by that?

> I bet you don't really consider that unreasonable - you might well even
> have written some of the alpha code yourself. Think of how the kernel
> converts back and forth between virtual kernel addresses and "struct page
> *". Where the virtual address can quite often be something like
> "zero_page[]" that the compiler knows about.

Not to detract from your point, but on Alpha the zero page is
defined as a constant:

system.h:#define ZERO_PGE       (PAGE_OFFSET+KERNEL_START_PHYS+0x0A000)

So in fact the compiler does not know about the object here.

> And when the compiler doesn't understand something, it shouldn't _think_
> that it does. That way lies madness.

At present we don't have a mechanism to tell the compiler that
it really doesn't understand what's going on here, despite the
seeming simplicity of the PLUS.

Off the top of my head, I don't know how to add such a thing
either.

At present, the best escape hatch if the kernel gets into really
nasty stuff that the compiler insists on misinterpreting is

  asm("" : "X"(foo) : "0"(foo));

That doesn't do precisely what we'd want from a compiler supported
feature though.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]