https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81432

            Bug ID: 81432
           Summary: Bogus fix-it hints from -Wmissing-braces when there
                    are excess elements
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

PR c/81405 identifies a crash in diagnostic-show-locus.c in the code to
consolidate fix-it hints during printing, with:

   gcc.dg/init-excess-1.c -Wmissing-braces

The fix-it hints generated by -Wmissing-braces appear to be bogus.

I'm keeping PR c/81405 to track the crash in diagnostic-show-locus.c when
printing them, but am opening this PR to track the bogus fix-it hints from
-Wmissing-braces; their effect can be seen by:


gcc -c ../../src/gcc/testsuite/gcc.dg/init-excess-1.c \
  -Wmissing-braces \
  -fdiagnostics-generate-patch \
  -fno-diagnostics-show-caret

(using -fno-diagnostics-show-caret to avoid the crash in PR c/81405)

and they contain e.g. this hunk:

@@ -13,36 +13,36 @@
 int a1[0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */
 int a2[0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */
 int a3[1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */
-int a4[][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */
-int a5[][0][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */
-int a6[][0][1] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */
-int a7[][1][0] = { 1, 2 }; /* { dg-warning "excess elements|near init" } */
+int a4[][0] = { {1}, {2 }}; /* { dg-warning "excess elements|near init" } */
+{int a5[][0][0] = { {{1}}}}, {{{2 }}}; /* { dg-warning "excess elements|near
init" } */
+{int a6[][0][1] = { {{1}}}}, {{{2 }}}; /* { dg-warning "excess elements|near
init" } */
+int a7[][1][0] = { {{1}}, {{2 }}}; /* { dg-warning "excess elements|near init"
} */

which is clearly nonsensical.

Reply via email to