[PATCH] C undefined behavior fix

Linus Torvalds torvalds@transmeta.com
Fri Jan 4 19:09:00 GMT 2002


On Fri, 4 Jan 2002 dewar@gnat.com wrote:
>
> The fact of the matter is that programs that execute undefined operations
> are the crap.

So says a language layer.

Welcome to the real world, where language lawyering is secondary, and
working programs (in the face of limitations of the languages) are
important.

There are lots of problems that simply push the boundary of what standard
languages can do. Obviously kernels tend to be one example of this, with
having to worry about concurrency in a language that doesn't even
understand what concurrency _is_, along with all the other issues.

You seem to prefer that such things would be written in assembly language,
just because the language itself doesn't understand what the problem space
is.

But the C language has exactly the notion of "implementation defined"
issues that _allow_ the programmer to take advantage of knowing more about
the machine and the environment than the language lawyers did. Thats' the
whole _point_ of "implementation defined" vs "undefined".

You may be used to Ada, where the language took a different tack: instead
of having "implementation specific" behaviour, the language itself was
extended. That's not how C works.

> SO no, it is not at ALL the case hat "everybody agrees" on anything of
> the kind. Undefined is undefined, it is not "undefined, not not so undefined
> as to offend Linus", since the latter is not a predicate we can define.

We're NOT talking about "undefined", we're talking about
_implementation_defined_, which is a totally different matter.

		Linus



More information about the Gcc mailing list