Skip to content

Commit fae4ed3

Browse files
authored
ES.103 examples updated, addresses Issue #1656 (#1659)
* ES.103 examples updated, addresses Issue #1656 * Fix cpplint report: Res-overflow0.cpp:18: Missing spaces around <= [whitespace/operators] [3]
1 parent bdccf49 commit fae4ed3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

CppCoreGuidelines.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13200,22 +13200,21 @@ Incrementing a value beyond a maximum value can lead to memory corruption and un
1320013200
##### Example, bad
1320113201

1320213202
int a[10];
13203-
a[10] = 7; // bad
13203+
a[10] = 7; // bad, array bounds overflow
1320413204

13205-
int n = 0;
13206-
while (n++ < 10)
13207-
a[n - 1] = 9; // bad (twice)
13205+
for (int n = 0; n <= 10; ++n)
13206+
a[n] = 9; // bad, array bounds overflow
1320813207

1320913208
##### Example, bad
1321013209

1321113210
int n = numeric_limits<int>::max();
13212-
int m = n + 1; // bad
13211+
int m = n + 1; // bad, numeric overflow
1321313212

1321413213
##### Example, bad
1321513214

1321613215
int area(int h, int w) { return h * w; }
1321713216

13218-
auto a = area(10'000'000, 100'000'000); // bad
13217+
auto a = area(10'000'000, 100'000'000); // bad, numeric overflow
1321913218

1322013219
##### Exception
1322113220

0 commit comments

Comments
 (0)