by qalmakka · 1w ago · 0 comments
For instance, C++ the only programming language that comes to my mind where the grammar is type 0 in the Chomsky classification - it means it has to be parsed with a Turing machine and thus every C++ compiler suffers from the halting problem.
This means that having a C++ compiler that will never crash or hang is literally mathematically impossible unless you stick to only parsing a subset of the grammar. Modern compilers bypass this by doing things like capping how many times templates can recurse, etc but this means that the frontend it will inevitably end up in unsavoury corners where it relies on its authors explicitly handling them - which sometimes they did not
Bullshit. These are compiler bugs that can be fixed. It's just not a priority because it doesn't affect normal use with valid code.
> This means that having a C++ compiler that will never crash or hang is literally mathematically impossible unless you stick to only parsing a subset of the grammar.
This is only a theoretical concern since every compiler will accept arbitrarily large programs anyway due to being built on fixed-width integer architectures which can only address finite amounts of memory. Real compiler can set reasonable limits where they can avoid both hangs and crashes.