Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 7
    $\begingroup$ Having undefined behaviour is rather unusual for a language, actually - you want the semantics of any code to be fully specified. Have a look at Why would a language have a concept of undefined behavior instead of raising an error? on Programming Language Design and Implementation to understand why C/C++ went this way. $\endgroup$ Commented Aug 18, 2023 at 10:10
  • 2
    $\begingroup$ "impossible to always detect undefined behavior at compile time" -- you don't have to detect everything at compile time, you can generate run-time checks. But this usually results in performance impacts that may be undesirable. $\endgroup$ Commented Aug 18, 2023 at 14:15
  • $\begingroup$ If the language is Turing-complete rather than Turing-hard, then every valid program is (somehow) equivalent to a Turing machine program - and the behavior of Turing machines is well-defined. So I suggest tweaking your question. $\endgroup$ Commented Aug 20, 2023 at 12:21
  • $\begingroup$ Either you misunderstood the person on Quora or they were wrong. The grammar/syntax absolutely does not have to contain undefined behavior. Undefined behavior in C was intentionally used to make the source code easily portable. $\endgroup$ Commented Aug 20, 2023 at 14:08
  • 1
    $\begingroup$ Note that no implementation of c is actually Turing-complete: it's equivalent to the requirement that a Turing machine must have an unbounded tape. Typical c implementations are stack, memory, and storage limited, and are equivalent to a Turing machine with a finite bounded tape: they aren't 'complete' because there are Turning problems they can't solve. $\endgroup$ Commented Aug 21, 2023 at 0:29