2 ms·
Though, of course, that's far from the only thing you need to recognise a syntactically valid C++ program. Deciding on syntax is Turing complete in C++. (Even
by eru 3y ago
Though, of course, that's far from the only thing you need to recognise a syntactically valid C++ program.
Deciding on syntax is Turing complete in C++. (Even in Pascal, you still need to check that you only used identifiers you declared before. That's not expressed in this diagram. But the extra rules required to get to the full language's syntax are fairly tame compared to C++.)
Syntax is Turing complete, and hence undecidable, in C++, because what's valid syntax depends on types in some instances, and the type system is Turing complete.
See eg https://medium.com/@mujjingun_23509/full-proof-that-c-grammar-is-undecidable-34e22dd8b664 https://medium.com/@mujjingun_23509/full-proof-that-c-gramma... or https://stackoverflow.com/questions/794015/what-do-people-mean-when-they-say-c-has-undecidable-grammar https://stackoverflow.com/questions/794015/what-do-people-me...
- Voultapher 3y agoIIRC because of some newer constexpr features you need a C++ VM with UB detection to parse C++, pretty wild. One of the reasons you have the choice between clang based source analysis tooling and incorrect tooling.
- eru 3y agoIt's not so much that clang is correct: there's no way to implement correct C++ according to the standard. But if you are using clang as your compiler, at least your tooling will agree with your compiler.