This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
Richard Henderson writes:
> No, it's still undefined (do you know what "foo" + 5 points to?).
As it happens, I *do* know what "foo" + offset points to, in the case
we were originally discussing.
Why is it undefined rather than implementation-defined? (That is a
serious question.)
I could understand it if you were saying that the *value* of "foo"[5]
is undefined, that is, that you could get any value of type char at
all, with no guarantees from the compiler about what value you will
get. But you (and others) are saying that the *operation* of
evaluating "foo"[5] is undefined and that if you write that, the
compiler has an excuse to generate code for system("rm -rf /") or
anything else it likes. That sounds like a cop-out to me.
> Would you _please_ just do the relocation in assembly? Do I need
> to write the code myself in order to end this thread for good?
Part of the problem is that Linus refuses to take the patch if he
thinks that it is working around a gcc bug (and he does think that).
When you say "do the relocation in assembly", do you mean write a
function in assembly to take an unrelocated address and return a
relocated address, or do you mean something different?
Paul.