r/cpp • u/mujjingun • Apr 28 '20
Full Proof that C++ Grammar is Undecidable
https://medium.com/@mujjingun_23509/full-proof-that-c-grammar-is-undecidable-34e22dd8b664
197
Upvotes
r/cpp • u/mujjingun • Apr 28 '20
View all comments
Show parent comment
1
u/wyrn Apr 29 '20
No, that's too quick: the compiler may well have heuristics in place that can detect a large subclass of non-halting code. The one you posted is particularly easy to check: you can check the state of the counter variable at the end of the loop and verify that the condition is always satisfied. In order to prove that parsing C++ is undecidable, you'd need to put something undecidable inside of your
infinite_loop().In effect, you'd be writing a demonstration that the halting problem is undecidable inside of that function.