1.. title:: clang-tidy - cppcoreguidelines-init-variables
2
3cppcoreguidelines-init-variables
4================================
5
6Checks whether there are local variables that are declared without an initial
7value. These may lead to unexpected behaviour if there is a code path that reads
8the variable before assigning to it.
9
10Only integers, booleans, floats, doubles and pointers are checked. The fix
11option initializes all detected values with the value of zero. An exception is
12float and double types, which are initialized to NaN.
13
14As an example a function that looks like this:
15
16.. code-block:: c++
17
18   void function() {
19     int x;
20     char *txt;
21     double d;
22
23     // Rest of the function.
24   }
25
26Would be rewritten to look like this:
27
28.. code-block:: c++
29
30   #include <math.h>
31
32   void function() {
33     int x = 0;
34     char *txt = nullptr;
35     double d = NAN;
36
37     // Rest of the function.
38   }
39
40Options
41-------
42
43.. option:: IncludeStyle
44
45   A string specifying which include-style is used, `llvm` or `google`. Default
46   is `llvm`.
47
48.. option:: MathHeader
49
50   A string specifying the header to include to get the definition of `NAN`.
51   Default is `<math.h>`.
52