Skip to content

Commit 5efbede

Browse files
committed
2 parents bcfd819 + 20da0a7 commit 5efbede

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

CppCoreGuidelines.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Supporting sections:
5050
* [NR: Non-Rules and myths](#s-not)
5151
* [RF: References](#s-references)
5252
* [Pro: Profiles](#s-profile)
53-
* [GSL: Guidelines support library](#gsl-guidelines-support-library)
53+
* [GSL: Guidelines support library](#s-gsl)
5454
* [NL: Naming and layout suggestions](#s-naming)
5555
* [FAQ: Answers to frequently asked questions](#s-faq)
5656
* [Appendix A: Libraries](#s-libraries)
@@ -767,7 +767,8 @@ We can of course pass the number of elements along with the pointer:
767767

768768
void g2(int n)
769769
{
770-
f2(new int[n], m); // bad: a wrong number of elements can be passed to f()
770+
// bad: the wrong number of elements can be passed to f2()
771+
f2(new int[n], n);
771772
}
772773

773774
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.
@@ -21248,7 +21249,7 @@ Once completely enforced through a combination of style rules, static analysis,
2124821249
* avoids undefined behavior by enforcing a key C++ language rule
2124921250

2125021251

21251-
# <a name="S-gsl"></a>GSL: Guidelines support library
21252+
# <a name="s-gsl"></a>GSL: Guidelines support library
2125221253

2125321254
The GSL is a small library of facilities designed to support this set of guidelines.
2125421255
Without these facilities, the guidelines would have to be far more restrictive on language details.

0 commit comments

Comments
 (0)