[LLVMdev] C as used/implemented in practice: analysis of responses

Renato Golin renato.golin at linaro.org
Wed Jul 1 05:29:29 PDT 2015


On 1 July 2015 at 13:10, Peter Sewell <Peter.Sewell at cl.cam.ac.uk> wrote:
> while attractive from the compiler-writer point of view, is just not
> realistic, given the enormous body of C code out there which does
> depend on some particular properties which are not guaranteed by the
> ISO standard.

There is also an enormous body of code that is just wrong. Do we have
to worry about getting that right, too? Trying to "understand" the
authors' intentions and do that instead of what they asked?

Where do we draw the line? What do we consider "a reasonable
deviation" from just "plain wrong"?

There is a large portion of non-standard documented behaviours in all
compilers, and GCC and Clang are particularly important here. Most
builtin functions, attributes, and extensions are supported by both
compilers in a similar way, and people can somewhat rely on it. But
the only true reliable sources are the standards.

However, the very definition of undefined behaviour is "here be
dragons", and that's something that was purposely done to aid
compilers at optimising code. You may try to unite the open source
compilers in many ways (as I tried last year), but trying to regulate
undefined behaviour is not one of them.


> That code is not necessarily all gospel, of course, far from it - but
> its existence does have to be taken seriously.

And we do! Though, in a completely different direction than you would expect. :)

You advocate for better consistent support, which is ok and I, for
one, have gone down that path multiple times. But in this specific
case, the way we take it seriously is by warning the users of the
potential peril AND abuse of it for performance reasons. This is a
sweet spot because novice users will learn the language and advanced
users will like the performance.

cheers,
--renato



More information about the llvm-dev mailing list