|
|
|
|
|
by RcouF1uZ4gsC
1107 days ago
|
|
Here is how to write a C compiler in Python that correctly compile the vast majority of C programs per the ISO C standard: print(“You have some form of undefined behavior, which means printing this is a valid response per the C standard”)
|
|
For C++ IFNDR ("Ill-formed, No diagnostic required") the situation is trickier because the affected programs (some unknowable but likely large proportion of all purported C++ code) are not well formed C++, the standard offers no hint as to what happens or why, since it constrains only the behaviour of a C++ compiler for well formed C++ programs.
† It's possible the C lexer claims to have some "Undefined Behaviour" cases like the C++ lexer, hence P2621 "UB? In my lexer?" which is a reference to a 2005 meme because C++ standards committee members are down with the kids, but that's clearly a standards text bug if so because it makes no sense to have UB in the lexer, these should just be ill-formed programs, you get a compiler error.