Skip to content

Commit c9503f1

Browse files
authored
Add Example to C26471
1 parent 5d5aa1f commit c9503f1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/code-quality/c26471.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,16 @@ helpviewer_keywords: ["C26471"]
88
# C26471 NO_REINTERPRET_CAST_FROM_VOID_PTR
99

1010
Don't use `reinterpret_cast`. A cast from void* can use `static_cast`. See [C++ Core Guidelines Type.1](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-reinterpretcast).
11+
12+
## Example
13+
```cpp
14+
void function(void* pValue)
15+
{
16+
{
17+
int* pointerToInt = reinterpret_cast<int*>(pValue); // C26471, use static_cast instead
18+
}
19+
{
20+
int* pointerToInt = static_cast<int*>(pValue); // Good
21+
}
22+
}
23+
```

0 commit comments

Comments
 (0)