Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 872 Bytes

c26462.md

File metadata and controls

34 lines (24 loc) · 872 Bytes
title ms.date f1_keywords helpviewer_keywords description
Warning C26462
03/22/2018
C26462
USE_CONST_POINTER_FOR_VARIABLE
C26462
CppCoreCheck rule C26462 that enforces C++ Core Guidelines Con.4

Warning C26462

The value pointed to by 'variable' is assigned only once, mark it as a pointer to const (con.4).

Remarks

Pointers to variables whose values remain unchanged should be marked as const.

Code analysis name: USE_CONST_POINTER_FOR_VARIABLE

Example

void useVal(int val);

void function1(int* ptr)
{
    int* p = ptr; // C26462, the value pointed to by p is unmodified
    ptr = nullptr;

    useVal(*p);
}

See also

C++ Core Guidelines con.4.