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

            Bug ID: 95312
           Summary: Missing quoting of format directives emitted by
                    -Wformat
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: asolokha at gmx dot com
  Target Milestone: ---

All gcc since 4.6, where -Wformat was initially introduced, emit the following
when compiling snippets like that w/ -Wformat:

#include <stdio.h>

int
foo (FILE *f, char *s)
{
  return fscanf (f, "%c%[^\n\n]", s);
}

% gcc-11.0.0 -fsyntax-only -Wformat -c po6k6b4n.c
po6k6b4n.c: In function 'foo':
po6k6b4n.c:6:29: warning: format '%[^

   ' expects a matching 'char *' argument [-Wformat=]
    6 |   return fscanf (f, "%c%[^\n\n]", s);
      |                        ~~~~~^~
      |                             |
      |                             char *

It seems wrong to me that the format directive is not quoted in the warning
text.

Reply via email to