Home > OS >  Is undefined versus undefined behavior
Is undefined versus undefined behavior

Time:02-04

The cppreference wording on front and back is surprisingly (at least for me) asymmetric.

front:

Calling front on an empty container is undefined.

back

Calling back on an empty container causes undefined behavior.

I know I am supposed to ask only one question, but still,

  1. Why it is different?, and
  2. What is the difference between is undefined and causes undefined behavior?

CodePudding user response:

In C , there is no difference between "undefined" and "undefined behavior." Both terms refer to the same concept: a situation in which the standard does not specify the expected outcome of a certain operation. In such cases, the behavior of the program is unpredictable.

CodePudding user response:

What is the difference between is undefined and causes undefined behavior?

They have the same meaning here.


Why it is different?,

Most likely because the page has been written by different authors or/and has not been updated for quite some time. Still, both are intended to mean the same thing.


Update

The page has now been updated to make the documentation language more consistent. In particular, now front says:

Calling front on an empty container causes undefined behavior.

  • Related