Skip to content

Commit 6b0e3d7

Browse files
committed
C++26 未初期化変数の読み取り : assert結果を明記
1 parent 7f7759e commit 6b0e3d7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lang/cpp26/erroneous_behavior_for_uninitialized_reads.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int g(bool b) {
5757
unsigned char c;
5858
unsigned char d = c; // 誤り起因動作ではない。dは誤り起因動作を引き起こす未初期化値をもつ
5959

60-
assert(c == d); // どちらの変数も整数昇格され誤り起因動作となる
60+
assert(c == d); // 常に真、誤り起因動作 (整数昇格)
6161

6262
int e = d; // 誤り起因動作 (型変換)
6363
return b ? d : 0; // bがtrueの場合に誤り起因動作
@@ -70,10 +70,11 @@ int main() {
7070
int e2 = d1; // 誤り起因動作
7171

7272
// 処理が続行した場合…
73-
assert(e1 == e2); // OK。誤り起因動作の結果で生成された値 (e1とe2) は、
73+
assert(e1 == e2); // 常に真、誤り起因動作ではない。
74+
// 誤り起因動作の結果で生成された値 (e1とe2) は、
7475
// 誤り起因動作を引き起こす値とはみなされない
75-
assert(e1 == d1); // 誤り起因動作
76-
assert(e2 == d1); // 誤り起因動作
76+
assert(e1 == d1); // 常に真、誤り起因動作
77+
assert(e2 == d1); // 常に真、誤り起因動作
7778

7879
// 誤り起因動作ではないが
7980
// d2は誤り起因動作を引き起こす未初期化値をもつ

0 commit comments

Comments
 (0)