Skip to content

Commit 616c00b

Browse files
committed
C++26 未初期化変数の読み取り : 今後の話を仕様から備考に移動
1 parent a81c832 commit 616c00b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

lang/cpp26/erroneous_behavior_for_uninitialized_reads.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,19 @@ int main() {
109109
}
110110
```
111111

112+
## 備考
113+
- 以下のようなケースでは、erroneous behaviorではなく未定義動作を引き起こす可能性がある:
114+
```cpp
115+
T* p; // 未初期化のポインタ。erroneous value (例としてヌルポインタ) をもつ
116+
bool b; // 未初期化の真理値。
117+
// bool値として妥当な値表現をもたない可能性がある
118+
// (例: 値表現が8bitで{0x00(false), 0x01(true)}の
119+
// 2通りのみとする処理系で0xCCをもつなど)
120+
121+
f(*p); // 間接参照は未定義動作を引き起こす
122+
g(b); // bが妥当な値表現をもつ場合にerroneous behavior、そうでなければ未定義動作
123+
```
124+
112125
### 今後、「erroneous behavior」に分類される可能性のある操作
113126

114127
現在、未定義動作に分類される以下の操作は、「erroneous behavior」に分類できる可能性がある。
@@ -124,19 +137,5 @@ int main() {
124137
| 契約違反 | 契約に関する現在の策定作業では、契約違反時になにが起こるべきかという問題に直面している。「erroneous behavior」という概念は有用な回答を与えてくれる可能性がある |
125138

126139

127-
## 備考
128-
- 以下のようなケースでは、erroneous behaviorではなく未定義動作を引き起こす可能性がある:
129-
```cpp
130-
T* p; // 未初期化のポインタ。erroneous value (例としてヌルポインタ) をもつ
131-
bool b; // 未初期化の真理値。
132-
// bool値として妥当な値表現をもたない可能性がある
133-
// (例: 値表現が8bitで{0x00(false), 0x01(true)}の
134-
// 2通りのみとする処理系で0xCCをもつなど)
135-
136-
f(*p); // 間接参照は未定義動作を引き起こす
137-
g(b); // bが妥当な値表現をもつ場合にerroneous behavior、そうでなければ未定義動作
138-
```
139-
140-
141140
## 参照
142141
- [P2795R5 Erroneous behaviour for uninitialized reads](https://open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2795r5.html)

0 commit comments

Comments
 (0)