You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 23, 2020. It is now read-only.
<h4id="diagnostics">Improvements to Clang's diagnostics</h4>
87
+
88
+
<p>Clang's diagnostics are constantly being improved to catch more issues,
89
+
explain them more clearly, and provide more accurate source information about
90
+
them. The improvements since the 3.1 release include:</p>
91
+
92
+
<ul>
93
+
<li><tt>-Wuninitialized</tt> has been taught to recognise uninitialized uses
94
+
which always occur when an explicitly-written non-constant condition is either
95
+
<tt>true</tt> or <tt>false</tt>. For example:
96
+
97
+
<pre>
98
+
int f(bool b) {
99
+
int n;
100
+
if (b)
101
+
n = 1;
102
+
return n;
103
+
}
104
+
105
+
<b>sometimes-uninit.cpp:5:10: <spanclass="warning">warning:</span> variable 'n' is sometimes uninitialized when used here [-Wsometimes-uninitialized]</b>
106
+
return n;
107
+
<spanclass="caret">^</span>
108
+
<b>sometimes-uninit.cpp:3:7: <spanclass="note">note:</span></b> uninitialized use occurs whenever 'if' condition is false
109
+
if (b)
110
+
<spanclass="caret">^</span>
111
+
<b>sometimes-uninit.cpp:2:8: <spanclass="note">note:</span></b> initialize the variable 'n' to silence this warning
112
+
int n;
113
+
<spanclass="caret">^</span>
114
+
<spanclass="caret"> = 0</span>
115
+
</pre>
116
+
117
+
This functionality can be enabled or disabled separately from
118
+
<tt>-Wuninitialized</tt> with the <tt>-Wsometimes-uninitialized</tt> warning
0 commit comments