Closed6

C11 標準ドキュメント 6.2.6 気が済むまで訳す

bayamasabayamasa

6.2.6.1 General

1 The representations of all types are unspecified except as stated in this subclause.

この項で語られていないことに関しては全て未定義です。
C言語は未定義処理が多いと呼ばれる理由がこれですね。

bayamasabayamasa

2 Except for bit-fields, objects are composed of contiguous sequences of one or more bytes, the number, order, and encoding of which are either explicitly specified or implementation-defined.

ビットフィールドを除いて、オブジェクトは連続する一つ以上のバイト、数、順序、および明示的に指定されているか、実装定義によって表されるエンコーディングから構成されます。

要するにオブジェクトはbyte/number/order/encodingで構成されていますよー的な感じですかね。

ビットフィールドとは自作の型です。C言語において型は自作することができます。
自作した型のオブジェクトの構成は未定義ということなんだと思います。
以下が参考になります
http://wisdom.sakura.ne.jp/programming/c/c38.html
https://qiita.com/tadnakam/items/5f935079d4e0e97c711d

bayamasabayamasa

3 Values stored in unsigned bit-fields and objects of type unsigned char shall be
represented using a pure binary notation.49)

符号なしビットフィールドおよびunsigned charのオブジェクトに格納された値は、純粋な2進法で表現する。

純粋な2進法の部分は注釈49に記載されています

  1. A positional representation for integers that uses the binary digits 0 and 1, in which the values
    represented by successive bits are additive, begin with 1, and are multiplied by successive integral
    powers of 2, except perhaps the bit with the highest position. (Adapted from the American National
    Dictionary for Information Processing Systems.) A byte contains CHAR_BIT bits, and the values of
    type unsigned char range from 0 to 2CHAR_BIT − 1.

2進数の0と1を使った整数の位置表現で、1で始まり連続する整数の2乗で乗算されます。ただし、最大値は除きます。(the American National Dictionary for Information Processing Systems.から引用)1バイトにはCHAR_BITビットが含まれており、その値は 型の値は、0から2CHAR_BIT - 1までの範囲です。

要するに一般的にイメージ出来る2進数の形ですね。
8bit であれば、0から 2^8 - 1までの長さです。

bayamasabayamasa

4 Values stored in non-bit-field objects of any other object type consist of n × CHAR_BIT
bits, where n is the size of an object of that type, in bytes. The value may be copied into
an object of type unsigned char [n] (e.g., by memcpy); the resulting set of bytes is
called the object representation of the value.

その他のオブジェクト型(non bit field)に格納される値は、n × CHAR_BIT ビットで構成されます。ここでのnは、そのタイプのオブジェクトのサイズ(バイト)です。値はmemcpyなどでunsigned char [n]型のオブジェクトにコピーすることができます。バイトがセットされた結果をオブジェクト表現と呼びます。

オブジェクト表現
https://software-dl.ti.com/codegen/docs/tiarmclang/compiler_tools_user_guide/compiler_manual/runtime_environment/object-representation-stdz0546454.html

Values stored in bit-fields consist of m bits, where m is the size specified for the bit-field. The object representation is the set of m bits the bit-field comprises in the addressable storage unit holding it. Two values (other than NaNs) with the same object representation compare equal, but values that compare
equal may have different object representations.

ビットフィールドに格納されている値はmビットで構成されています。このmはビットフィールドに指定されたサイズです。オブジェクト表現は共用体が保持するアドレス可能な記憶装置の中のビットフィールドが構成するm個のビットのセットです。同じオブジェクト表現を持つ2つの値(NaN以外)は比較して等しいですが、値が比較して等しいときは異なるオブジェクト表現を持つ場合があります。

ビットフィールドの解説です。
共用体が持っているメモリサイズの中の指定したmビットがオブジェクト表現になるということですね
2つのオブジェクト表現が等しい場合、値は等しいですが値が等しい場合にはオブジェクト表現が等しいとは限らないということです。

bayamasabayamasa

5 Certain object representations need not represent a value of the object type. If the stored
value of an object has such a representation and is read by an lvalue expression that does
not have character type, the behavior is undefined. If such a representation is produced
by a side effect that modifies all or any part of the object by an lvalue expression that
does not have character type, the behavior is undefined.50) Such a representation is called
a trap representation.

特定のオブジェクト表現はオブジェクト型の値を表す必要はありません。もしオブジェクトに格納された値が同様のオブジェクト表現を持ち、char型ではないlvalue式で読み取られた場合、その動作は未定義です。 このような表現がchar型ではないlvalue式によってオブジェクトの全部または一部を変更する副作用によって生成された場合、その動作は未定義である50)。このような表現はトラップ表現と呼ばれる。

ここは特にわかりにくいのですが、要するにトラップ表現の説明ですね。

ipaからの引用

トラップ表現とは、システムが内部処理用に特別に定義している値のことで、2 の補数表現を使っている場合は最上位ビットが 1 でそれ以外が 0 である値を使います。
https://www.ipa.go.jp/files/000045165.pdf

この辺もわかりやすい説明かも。こっちも訳したい。

https://stackoverflow.com/questions/6725809/trap-representation

またlvalueの訳は左辺値だと思っていたのですがどうやら違うようです。
https://qiita.com/yumetodo/items/8eae5714a6cfe1c0407d

  1. Thus, an automatic variable can be initialized to a trap representation without causing undefined
    behavior, but the value of the variable cannot be used until a proper value is stored in it.

従って、未定義の動作を引き起こすことなく自動的に変数がトラップ表現で初期化されうることもあります。しかし適切な値が格納されるまで、その変数の値は使用できません。

このスクラップは2021/08/20にクローズされました