C23

Overview

The five latest C standards are called C89, C99, C11, C17, and C23.

A C program can be seen as a sort of machine that manipulates values: the particular values that variables of the program have at a given time, and also intermediate values that are the result of computed expressions.

This quote describes C's abstract state machine. Whatever instructions a C program compiles down to is "unimportant" provided that all observable states are correctly reproduced. This is the essence of optimization.

Values

An object is a region of data storage in the execution environment, the contents of which can represent values. An lvalue is an expression (with non-void object type) that potentially designates an object. An rvalue is the "value of the expression."

A lvalue is said to be modifiable if it can appear on the left hand side of an assignment operator. For example, array names are lvalues but not modifiable lvalues.

The notion of a value in C is an abstract entity. It exists beyond the program or the representation of the value in the program. For example, the value 0 (no matter how its represented) added to variable x should always yield result x regardless of platform.

Types

Types are additional properties that C associates with values. All values have a type that is statically determined and all possible operations on a value are determined by its type.

Representations

The binary representation of a type is the model used to represent values of said type on a given platform. The object representation of a type determines how values are stored in memory, disk, etc.

Compilation

Most compilation systems provide a compiler driver that invokes a c23/preprocessor, compiler, assembler, and linker:

  1. The C preprocessor (e.g. cpp) translates C source files (.h and .c) into ASCII intermediate files (.i).
  2. The C compiler (e.g. cc1) translates intermediate files into ASCII assembly-language files (.s).
  3. The assembler translates assembly-language files into relocatable object files (.o).
  4. The linker bundles all relocatable object files and produces an executable object file.

Character Sets

From the perspective of the compiler, there exist three character sets:

  1. The physical character set refers to the characters used by source files on disk.
  2. The source character set refers to the characters translated into for compilation.
  3. The execution character set refers to the characters translated into for execution.

Linkage

An identifier declared in different scopes or in the same scope multiple times can be made to refer to the same object or function by a process called linkage. There are three kinds of linkage: external, internal, and none.

Sequencing

There exists four sequencing relationships in C:

  1. Sequenced before: One evaluation happens completely before another.
  2. Sequenced after: One evaluation happens completely after another.
  3. Indeterminately sequenced: Evaluations are unordered relative to one another, but they may not interleave.
  4. Unsequenced: Evaluations can happen in any order and may interleave.

These sequence relationships can be influenced syntactically via sequence points which impose some execution serialization. Note though that these impose some order. They may or may not allow disambiguating which order is actually taken.

Sequence Points

The following constitute known sequence points:

Powered by Forestry.md