Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 955 Bytes

c26494.md

File metadata and controls

41 lines (32 loc) · 955 Bytes
title description ms.date f1_keywords helpviewer_keywords
Warning C26494
Learn more about: Warning C26494 VAR_USE_BEFORE_INIT.
03/22/2018
C26494
VAR_USE_BEFORE_INIT
C26494

Warning C26494

Variable 'variable' is uninitialized. Always initialize an object.

Remarks

This check requires local variables to be initialized at the declaration or in the following statement.

Example

#include <iostream>
void function()
{
    int myVal; // C26494, Variable is uninitialized
    std::cout << myVal; // C6001
}

To fix the issue, initialize the variable at the declaration.

#include <iostream>
void function()
{
    int myVal{};
    std::cout << myVal;
}

See also

ES.20: Always initialize an object
C++ Core Guidelines Type.5