4 ms·
C would have been great as a portable assembler. E.g. if a syntactic + mapped to the hardware `add` instruction, that's pretty predictable! But it doesn't; it m
by titzer 3y ago
C would have been great as a portable assembler. E.g. if a syntactic + mapped to the hardware `add` instruction, that's pretty predictable! But it doesn't; it maps to the hardware `add` modulo compiler optimizations (like folding and strength reduction, which are done assuming overflow and other tricky parts are UB). Basically everywhere UB is permitted by the spec is so compilers don't have to handle the tricky cases, don't have to give semantics for buggy programs, or even help in debugging, and can make what would be unsound optimizations if the operations truly represented the target CPU's "weird" add semantics.
- pizlonator 3y agoJust toss enough compiler flags at clang and make sure to occasionally use inline asm snippets to throw off the compiler's optimizations. Then you're GTG