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
Post-commit review feedback on
#137166 raised a concern from
the Linux kernel about wanting to silence the new diagnostic when the
uninitialized object is a const member of a structure. These members can
be initialized later if the containing object is non-const, such as
through a call to memset, for example.
This splits the diagnostic groups into:
```
-Wc++-compat
-Wdefault-const-init
-Wdefault-const-init-field
-Wdefault-const-init-var
-Wdefault-const-init-unsafe
-Wdefault-const-init-field-unsafe
-Wdefault-const-init-var-unsafe
```
---------
Co-authored-by: Mariya Podchishchaeva <[email protected]>
cxx-note {{default constructor of 'W' is implicitly deleted because field 'j' of const-qualified type 'const int' would not be initialized}}
18
12
19
13
voidf() {
20
-
structSs1; // unsafe-warning {{default initialization of an object of type 'struct S' with const member leaves the object uninitialized and is incompatible with C++}} \
14
+
structSs1; // unsafe-field-warning {{default initialization of an object of type 'struct S' with const member leaves the object uninitialized and is incompatible with C++}} \
21
15
cxx-error {{call to implicitly-deleted default constructor of 'struct S'}}
22
16
structSs2= { 0 };
23
17
}
24
18
voidg() {
25
-
structTt1; // unsafe-warning {{default initialization of an object of type 'struct T' with const member leaves the object uninitialized and is incompatible with C++}} \
19
+
structTt1; // unsafe-field-warning {{default initialization of an object of type 'struct T' with const member leaves the object uninitialized and is incompatible with C++}} \
26
20
cxx-error {{call to implicitly-deleted default constructor of 'struct T'}}
27
21
structTt2= { { 0 } };
28
22
}
@@ -31,13 +25,13 @@ void h() {
31
25
structUu2= { { 0 }, 0 };
32
26
}
33
27
voidx() {
34
-
structVv1; // unsafe-warning {{default initialization of an object of type 'struct V' with const member leaves the object uninitialized and is incompatible with C++}} \
28
+
structVv1; // unsafe-field-warning {{default initialization of an object of type 'struct V' with const member leaves the object uninitialized and is incompatible with C++}} \
35
29
cxx-error {{call to implicitly-deleted default constructor of 'struct V'}}
36
30
structVv2= { 0 };
37
31
structVv3= { 0, { 0 } };
38
32
}
39
33
voidy() {
40
-
structWw1; // unsafe-warning {{default initialization of an object of type 'struct W' with const member leaves the object uninitialized and is incompatible with C++}} \
34
+
structWw1; // unsafe-field-warning {{default initialization of an object of type 'struct W' with const member leaves the object uninitialized and is incompatible with C++}} \
41
35
cxx-error {{call to implicitly-deleted default constructor of 'struct W'}}
42
36
structWw2= { 0 };
43
37
structWw3= { { 0 }, 0 };
@@ -47,17 +41,17 @@ void y() {
47
41
externconstinti;
48
42
constinti=12;
49
43
50
-
staticconstintj; // c-warning {{default initialization of an object of type 'const int' is incompatible with C++}} \
44
+
staticconstintj; // zero-init-var-warning {{default initialization of an object of type 'const int' is incompatible with C++}} \
51
45
cxx-error {{default initialization of an object of const type 'const int'}}
52
-
constintk; // c-warning {{default initialization of an object of type 'const int' is incompatible with C++}} \
46
+
constintk; // zero-init-var-warning {{default initialization of an object of type 'const int' is incompatible with C++}} \
53
47
cxx-error {{default initialization of an object of const type 'const int'}}
54
-
conststructSs; // c-warning {{default initialization of an object of type 'const struct S' is incompatible with C++}} \
48
+
conststructSs; // zero-init-field-warning {{default initialization of an object of type 'const struct S' is incompatible with C++}} \
55
49
cxx-error {{call to implicitly-deleted default constructor of 'const struct S'}}
56
50
57
51
voidfunc() {
58
-
constinta; // unsafe-warning {{default initialization of an object of type 'const int' leaves the object uninitialized and is incompatible with C++}} \
52
+
constinta; // unsafe-var-warning {{default initialization of an object of type 'const int' leaves the object uninitialized and is incompatible with C++}} \
59
53
cxx-error {{default initialization of an object of const type 'const int'}}
60
-
staticconstintb; // c-warning {{default initialization of an object of type 'const int' is incompatible with C++}} \
54
+
staticconstintb; // zero-init-var-warning {{default initialization of an object of type 'const int' is incompatible with C++}} \
61
55
cxx-error {{default initialization of an object of const type 'const int'}}
0 commit comments