Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> WUFFS promises it's correct

With respect to what standard of correctness? If the answer is that the object code is guaranteed to behave according to the source according to the C standard that is a useless guarantee because of the possibility that there is UB in the source code, in which case the compiler could release the kraken and it would still be "correct".



I should have said "safe" rather than correct here.

WUFFs promises that you can't write unsafe things. For example you can't have arithmetic overflow in WUFFS. Every time it sees arithmetic in your code the compiler is trying to decide why this operation might overflow. If you add together two 8-bit variables and put the result in a 16-bit variable, that doesn't overflow, but if you try to put the result in another 8-bit integer variable the compiler assumes unless it can see otherwise that this is an overflow, which is forbidden, so your code doesn't compile.

Buffer overflows are the same, if you're indexing into a buffer with an 8-bit unsigned variable and the buffer has 400 entries it's cool. If it has 100 entries but the compiler has concluded this variable can only be between say, 20 and 48 then that's cool too. But if the compiler can't prove this variable isn't 100 then you've got a potential buffer overflow and the code does not compile.

The C code is an output from WUFFS. WUFFS says "This C code is definitely safe" and then CompCert says "This object code is definitely a correct implementation of your C code" so the result is WUFFS compiled by CompCert is definitely safe object code.


But I can ask the exact same question: safe by what standard?

> you can't have arithmetic overflow in WUFFS

That seems improbable. Can I write x++? Because if I can, then I can have an arithmetic overflow.

> Buffer overflows are the same

That seems improbable. Can I write *p++? Because if I can then I can overflow a buffer.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: