From fae4ed3768ec6361a71caba7667360ed115abc15 Mon Sep 17 00:00:00 2001 From: David B <67195754+dboyce-gh@users.noreply.github.com> Date: Thu, 3 Sep 2020 19:17:11 +0100 Subject: [PATCH] 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] --- CppCoreGuidelines.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 8240d48..a9248a7 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -13200,22 +13200,21 @@ Incrementing a value beyond a maximum value can lead to memory corruption and un ##### Example, bad int a[10]; - a[10] = 7; // bad + a[10] = 7; // bad, array bounds overflow - int n = 0; - while (n++ < 10) - a[n - 1] = 9; // bad (twice) + for (int n = 0; n <= 10; ++n) + a[n] = 9; // bad, array bounds overflow ##### Example, bad int n = numeric_limits::max(); - int m = n + 1; // bad + int m = n + 1; // bad, numeric overflow ##### Example, bad int area(int h, int w) { return h * w; } - auto a = area(10'000'000, 100'000'000); // bad + auto a = area(10'000'000, 100'000'000); // bad, numeric overflow ##### Exception