[PATCH] C undefined behavior fix

dewar@gnat.com dewar@gnat.com
Fri Jan 4 17:29:00 GMT 2002


<<The standard defines "implementation defined" to mean that the
implementation will document the definition.  We have done so, in
extend.texi in the CVS tree.  The only problem is that the definition we
propose is internally inconsistent.  This means that the extend.texi
definition has a problem.
>>

Nope, nothing is inconsistent about it. Reread my previous messages.
One part of the definition says what bits you get. The other part says
what happens if you try to use the bits.

The trouble is, as Florian points out, that the thinking here is at too
low a level, in terms of generated machine code. As long as you think of
semantics this way, you will get nowhere. 

The source of your thinking this is an inconsistency is rooted in this
wrong-thinking. You are thinking "if the bit pattern is the x, then I
know what happens if you use x as a pointer, therefore I know what to
expect the code to do". Unfortunately, the therefore just does not follow.

Now, it would certainly seem that we want some way of dealing with
arbitrary pointer values in gcc (never mind the standard, it is really
not relevant here to what we want, since it will certainly let us do
what we want). The trick (and it is not easy) is to define what we mean
by this in formal semantic terms.



More information about the Gcc mailing list