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: Serious code generation/optimisation bug (I think)


Zoltán Kócsi wrote:

You say: "You can't dereference a NULL pointer"

I say: "You shouldn't dereference a NULL pointer"

Yes, but the standard says can't in effect, and gives no idea of what it might mean to dereference a null pointer.

I shouldn't but I most certainly can. I can generate a NULL pointer
where the compiler can not prove (at compile time) that it is NULL. If I dereference it, then whatever happens is my problem.

Indeed, according to the C standard, anything can happen, since the program is undefined, so you should not be complaining about the program behaving in a particular way.

I should not
do that but I can and if I do, I take the consequences.

You saw the legitimate consequences, and you don't like them, so you don't really mean this.

The compiler,
in my opinion, must not assume that just because something should not
be done it can not possibly be done. Actually, it should not assume
things at all. Rather, it should prove things before making a
transformation. If it makes a transformation based on nothing more than its assumptions, then at least it should give me a warning.

The compiler is free to make any transformation that has the property that if the program is defined C, then the transformation will not affect the defined semantics. It is fine from a language point of view for a transformation to have any effect at all on an undefined program.

See my problem?

You are thinking about things at the wrong level, you have some notion that the C you write is transformed in a manner you understand into machine language, but there is no such guarantee, the only guarantee is that the resulting binary program implements the semantics of the program if the execution is defined.

Zoltan


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