by Neywiny · 2w ago · 0 comments
Because C++ is simply too complex, and on certain corner cases the compiler can easily crash or leak memory. That is especially true for incomplete code in the middle of editing: a huge downstream user base tests compilers on complete code, while very few people test them on half-written code, where the compiler mostly falls back on best-effort heuristics
It's the compiler that crashes. Both clangd and clice are built on top of the same compiler (clang) which is why both experience a crash on the same code.
I could understand them showing off crash recovery by using code deliberately written to crash the language server, and so not being something you can "fix".
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.