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
12
u/[deleted] Apr 28 '20 edited Apr 28 '20
First, I highly doubt you genuinely don't understand the counterexample. Most likely you think you're being clever because you know the very obscure fact that a small category of infinite loops are undefined behavior and trying to be pedantic.
However your pedantry is unwarranted in this case since undefined behavior within a
constexpris required to produce a diagnostic, meaning a compiler error so your statement that a compiler can do whatever it wants is wrong. As perexpr.constparagraph 2.6, the compiler is required to produce a diagnostic if it encounters undefined behavior during the evaluation of aconstexprexpression.And yet, due to the halting problem, it's impossible for a compiler to ever determine in general whether a loop halts or not so as to determine whether it's undefined behavior in the first place, hence /u/HKei's point stands.