| title | Warning C26494 | ||
|---|---|---|---|
| description | Learn more about: Warning C26494 VAR_USE_BEFORE_INIT. | ||
| ms.date | 03/22/2018 | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
Variable 'variable' is uninitialized. Always initialize an object.
This check requires local variables to be initialized at the declaration or in the following statement.
#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;
}ES.20: Always initialize an object
C++ Core Guidelines Type.5