3 ms·
> The C standard leaves a lot "undefined" or "implementation defined" that is actually well-defined on a concrete machine the compiled code runs on. This assum
by muldvarp 3y ago
> The C standard leaves a lot "undefined" or "implementation defined" that is actually well-defined on a concrete machine the compiled code runs on.
This assumes there is a one-to-one correspondence between C constructs and machine code, which isn't true. C isn't a "portable assembler" and compilers are luckily able to choose whatever machine code they think will perform best under the assumption that there is no undefined behavior.
> But it will be a sucky compiler.
I don't think gcc or clang are sucky compilers at all. In fact, their ability to aggressively optimize valid code is extremely helpful for producing high-performance programs.
> C ≠ The ANSI/ISO C standard
So C is defined neither by the standard _nor_ by existing implementations and is instead defined to be whatever your headcanon is?
- mpweiher 3y ago> This assumes there is a one-to-one correspondence between C constructs and machine code No it does not. > which isn't true. Actually, it is true in a vast majority of cases. > C isn't a "portable assembler" Not sure why people keep repeating this despite it being so obviously and patently untrue: "Committee did not want to force programmers into writing portably, to preclude the use of C as a “high-level assembler:” https://www.open-std.org/JTC1/SC22/WG14/www/docs/n897.pdf https://www.open-std.org/JTC1/SC22/WG14/www/docs/n897.pdf p10, line 39 "C code can be portable. " line 30