c/language/lifetime

Every in C exists, has a constant address, retains its last-stored value (except when the value is indeterminate) over a portion of program execution known as this object's lifetime.

For the objects that are declared with automatic, static, and thread storage duration, lifetime equals their (note the difference between non-VLA and VLA automatic storage duration).

For the objects with allocated storage duration, the lifetime begins when the allocation function returns (including the return from realloc) and ends when the realloc or deallocation function is called. Note that since allocated objects have no, the type of the lvalue expression first used to access this object becomes its.

Accessing an object outside of its lifetime is undefined behavior.

A pointer to an object (or one past the object) whose lifetime ended has indeterminate value.

Temporary lifetime
Struct and union objects with array members (either direct or members of nested struct/union members) that are designated by, have temporary lifetime. Temporary lifetime begins when the expression that refers to such object is evaluated and ends.

Any attempt to modify an object with temporary lifetime results in undefined behavior.