Closed elfring closed 6 years ago
Thank you for the suggestion, but I intentionally omit error checking for the memory exhaustion situation, because we cannot really handle such situation. If the memory is so tight that malloc can fail, the entire system becomes unstable (e.g. the kernel chooses a process to kill to free up some amount of memory). So, your program becomes unstable even if you correctly handle such situation. 9cc doesn't handle malloc failure, so it crashes with SEGV when malloc fails. That's fine. In practice, that won't cause any trouble.
I'm trying not to make 9cc bullet-safe. Rather, I trust people don't shoot us. That design choice greatly simplifies its code, as you probably can see.
How do you think about to improve static source code analysis also for this software?
You probably should unlearn these kind of "best practices". I'm trying to keep my code as simple as I can so that you don't really need any higher-level metaprogramming.
How do you think about to avoid that this software can depend on undefined behaviour?
Would you like to add more error handling for return values from functions like the following?