diff --git a/rules/S6871/cfamily/rule.adoc b/rules/S6871/cfamily/rule.adoc index 0c451e57acc..285ba2c8b39 100644 --- a/rules/S6871/cfamily/rule.adoc +++ b/rules/S6871/cfamily/rule.adoc @@ -193,12 +193,12 @@ struct ArrayMember { }; -int a1[5] = {1, 2, 3}; // Noncompliant -Pod p1{1}; // Noncompliant -int c1[2][2] = {{1}, {2}}; // Noncompliant -Pod c2[3] = {{1, 2}, {2}}; // Noncompliant -PodPair c3 = {{1}}; // Noncompliant -ArrayMember c4 = {1, 2, 3}; // Noncompliant +int a1[5] = {1, 2, 3}; // Noncompliant +Pod p1{1}; // Noncompliant +int c1[2][2] = {{1}, {2}}; // Noncompliant +Pod c2[3] = {{1, 2}, {2}}; // Noncompliant +PodPair c3 = {{1}}; // Noncompliant +ArrayMember c4 = {1, {2, 3}}; // Noncompliant ---- ==== Compliant solution @@ -226,11 +226,12 @@ Pod p1{1, 0}; // Compliant int c1[2][2] = {{1, 0}, {2, 0}}; // Compliant Pod c2[3] = {{1, 2}, {2, 0}, {0, 0}}; // Compliant PodPair c3 = {{1, 0}, {0, 0}}; // Compliant -ArrayMember c4 = {1, 2, 3, 0, 0, 0}; // Compliant +ArrayMember c4 = {1, {2, 3, 0, 0, 0}}; // Compliant ---- Or use zero-initialization syntax for `c2` and `c3`: ------ +[source,cpp] +---- Pod c2[3] = {{1, 2}, {2, 0}, {}}; // Compliant PodPair c3{{1, 0}, {}}; // Compliant ---- @@ -315,6 +316,7 @@ Pod p1{1}; // Compliant ArrayMember m1{11}; // Compliant ---- +TODO: going extra mile with `int arr[2][2] = {1, 2, 3};` == Resources