Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 803 Bytes

File metadata and controls

31 lines (23 loc) · 803 Bytes
title C26462
ms.date 03/22/2018
ms.topic reference
f1_keywords
C26462
helpviewer_keywords
C26462
description CppCoreCheck rule C26462 that enforces C++ Core Guidelines Con.4

C26462 USE_CONST_POINTER_FOR_VARIABLE

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

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

See also

C++ Core Guidelines con.4.

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);
}