3 ms·
> Having some undefined behavior in your code is just a bug, it has nothing to do with being complicated or compiling to machine code. In theory, yes. In pract
by pcwalton 11y ago
> Having some undefined behavior in your code is just a bug, it has nothing to do with being complicated or compiling to machine code.
In theory, yes. In practice, all C/C++ programs have undefined behavior in them, so you have to understand what compilers do to really understand your code.
> It's not nearly as complex, in fact there are many people who understand quite well what the code compiles to.
Not true in my experience. The only people who really understand it are, by and large, compiler developers. There are very few compiler developers.
> Try guessing what Java compiles to.
I know what Java compiles to more or less as well as I know what C++ compiles to. The only real difference is in GC (which is quite simple--inline a nursery bump and fall back to a malloc-like slow path if it fails) and ICs, which are a lot less complicated than things like alias-analysis-sensitive load forwarding.
- fanf2 11y agoRe. undefined behaviour, this fairly definitive paper agrees that it has gone too far: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1637.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1637.pdf