From 7c991f0e7ec0b09a2f645369a7ab90064551bacb Mon Sep 17 00:00:00 2001 From: Thibault Kruse Date: Wed, 24 Aug 2016 12:46:38 +0200 Subject: [PATCH] fix varname --- CppCoreGuidelines.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 81b447c..4b56a65 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -16997,10 +16997,10 @@ Use of these casts can violate type safety and cause the program to access a var }; Derived1 d1; - Base* p = &d1; // ok, implicit conversion to pointer to Base is fine + Base* p1 = &d1; // ok, implicit conversion to pointer to Base is fine // BAD, tries to treat d1 as a Derived2, which it is not - Derived2* p2 = static_cast(p); + Derived2* p2 = static_cast(p1); // tries to access d1's nonexistent string member, instead sees arbitrary bytes near d1 cout << p2->get_s(); @@ -17136,7 +17136,7 @@ Note that a C-style `(T)expression` cast means to perform the first of the follo Base* p1 = &d1; // ok, implicit conversion to pointer to Base is fine // BAD, tries to treat d1 as a Derived2, which it is not - Derived2* p2 = (Derived2*)(p); + Derived2* p2 = (Derived2*)(p1); // tries to access d1's nonexistent string member, instead sees arbitrary bytes near d1 cout << p2->get_s();