12 votes

What are the conditions necessary for a programming language to have no undefined behavior?

First off, let's be clear on what "undefined behaviour" is. In just C alone (and this is the understanding inherited by C++), there are two possible meanings, depending on which version of ...
Pseudonym's user avatar
  • 22k
11 votes

Does the first incompleteness theorem imply that any Turing complete programming language must have undefined behavior?

No, it doesn't require that. These are two orthogonal issues. You can easily define a new programming language where you provide fully defined semantics for all operations; yet it can be Turing ...
D.W.'s user avatar
  • 158k
8 votes

What are the conditions necessary for a programming language to have no undefined behavior?

The C language may say "if you do X, then whatever the result is, is not a violation of the C Standard". "Whatever the result is" can include the result that you hoped for, some ...
gnasher729's user avatar
  • 29.4k
5 votes
Accepted

What are the conditions necessary for a programming language to have no undefined behavior?

The problem of statically detecting undefined behavior has nothing to do with undefinedness as such. It's just impossible to prove in general that programs in a Turing-complete language will do ...
benrg's user avatar
  • 2,112
4 votes

Does the first incompleteness theorem imply that any Turing complete programming language must have undefined behavior?

Your intuition is incorrect. The analogies you're trying to draw are not there, even though it's understandable you would expect them. Programming languages can be defined as formal systems, but they ...
Andrej Bauer's user avatar
  • 30.3k
4 votes

What are the conditions necessary for a programming language to have no undefined behavior?

So my question now is, what conditions need to be imposed on a Turing complete language in order to guarantee that all possible programs written in the language will have fully defined behavior ...
yeputons's user avatar
  • 256
3 votes

What are the conditions necessary for a programming language to have no undefined behavior?

Starting from the C/C++ languages, ruling out all undefined behavior would be very hard. But if you're designing a language from scratch, it's not difficult at all to rule out undefined behavior. Many ...
Glenn Willen's user avatar
3 votes

What are the conditions necessary for a programming language to have no undefined behavior?

Lets look at a sample program ...
QuadmasterXLII's user avatar
2 votes

Does the first incompleteness theorem imply that any Turing complete programming language must have undefined behavior?

The incompleteness theorem only applies to formal systems that can express a certain amount of arithmetic. In particular, they have to support statements of the form $\forall n\in\mathbb N. P(n)$, ...
benrg's user avatar
  • 2,112
1 vote

What are the conditions necessary for a programming language to have no undefined behavior?

I would argue that there is one very specific requirement to defeat undefined behaviour: that the programming language designers control the hardware design. Undefined behaviour exists notionally to ...
Steve's user avatar
  • 494

Only top scored, non community-wiki answers of a minimum length are eligible