From 80ddcb07cadfdacdad88ffcdad7d0a756e6697e3 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Sun, 28 Sep 2025 22:33:36 -0400 Subject: [PATCH 1/3] [P.6] trivial: s/f/f2/ (#2288) A comment in a code example was intended to refer to a function named "f2", but the comment uses the name "f" instead, presumably because the code was copied from the previous example; this commit fixes the typo. --- CppCoreGuidelines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index d8fb95536..d8bad36e2 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -767,7 +767,7 @@ We can of course pass the number of elements along with the pointer: void g2(int n) { - f2(new int[n], n); // bad: a wrong number of elements can be passed to f() + f2(new int[n], n); // bad: a wrong number of elements can be passed to f2() } Passing the number of elements as an argument is better (and far more common) than just passing the pointer and relying on some (unstated) convention for knowing or discovering the number of elements. However (as shown), a simple typo can introduce a serious error. The connection between the two arguments of `f2()` is conventional, rather than explicit. From 812cea62bdf3a901e917aed3468f2b4171fd104f Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Sun, 28 Sep 2025 21:47:12 -0500 Subject: [PATCH 2/3] [P.6] trivial: Move a code comment (//...) to the line above the code (#2288) This matches the way the previous, related code example is written, a fact you can observe more readily by reviewing the patch of this commit with larger context: git diff -U19 Specifically, the previous example looks like this: // bad: the number of elements is not passed to f() f(new int[n]); --- CppCoreGuidelines.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index d8bad36e2..6f15065fe 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -767,7 +767,8 @@ We can of course pass the number of elements along with the pointer: void g2(int n) { - f2(new int[n], n); // bad: a wrong number of elements can be passed to f2() + // bad: a wrong number of elements can be passed to f2() + f2(new int[n], n); } Passing the number of elements as an argument is better (and far more common) than just passing the pointer and relying on some (unstated) convention for knowing or discovering the number of elements. However (as shown), a simple typo can introduce a serious error. The connection between the two arguments of `f2()` is conventional, rather than explicit. From 3c459b5f4b9953452e50fe9721c25ab9a054fbe2 Mon Sep 17 00:00:00 2001 From: Michael Witten Date: Sun, 28 Sep 2025 22:55:19 -0400 Subject: [PATCH 3/3] [P.6] trivial: s/a/the/ (#2288) While "a wrong number can be passed" makes sense (and there are perhaps good philosophical reasons to prefer it), I believe that the more natural way to say it in common English is "the wrong number can be passed"; thus, this commit changes "a" to "the" in the comment of a code example. --- CppCoreGuidelines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 6f15065fe..309aa5e60 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -767,7 +767,7 @@ We can of course pass the number of elements along with the pointer: void g2(int n) { - // bad: a wrong number of elements can be passed to f2() + // bad: the wrong number of elements can be passed to f2() f2(new int[n], n); }