From d4cd200b4b3f6db695844db2647e8baff6521962 Mon Sep 17 00:00:00 2001 From: kalyanmysore Date: Thu, 18 Sep 2025 18:17:54 -0500 Subject: [PATCH] Fixed a typo. local var name Under P.6, there are a few examples where the size is passed separately. The local variable name for the size is n. There is a typo and m is passed instead. There is no local var named m. It should be n. --- CppCoreGuidelines.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 6bb7a0ab8..725d1c716 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], m); // 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 f() } 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. @@ -785,7 +785,7 @@ The standard library resource management pointers fail to pass the size when the void g3(int n) { - f3(make_unique(n), m); // bad: pass ownership and size separately + f3(make_unique(n), n); // bad: pass ownership and size separately } ##### Example