[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: Re: -Wformat warnings
From: "Andrew Morton" <morton () nortelnetworks ! com>
Date: 2000-01-31 4:52:38
[Download RAW message or body]
"Kaveh R. Ghazi" wrote:
>
> > From: Martin Buchholz <martin@xemacs.org>
> >
> > The -Wformat warnings are nice, but how does one turn them off when
> > the format string arg is non-constant? In my opinion, the following
> > warning should never appear - it's a useless meta-warning. There
> > doesn't seem to be an obvious way to suppress them.
> >
> > /xemacs/ws/dev/src/lread.c:312: warning: format not a string
> > literal, argument types not checked
> >
> > It would be nice if warnings could be properly done for this:
> >
> > fprintf (stderr,
> > (c >= 0x20 && c <= 0x7E) ? "UU%c" :
> > ((c == '\n') ? "UU\\n\n" : "UU\\%o"), c);
> >
>
> Yes many people have complained about this.
Yup. The unique thing about this warning is that there are valid
circumstances under which it's _impossible_ to remove it. Kinda
devalues -Werror, no?
> ...
>
> Anyway, no one has stepped up to the plate and provided a way to turn
> it off independent of -Wformat. But I expect there to be one before
> the next official release.
Here's my proposal:
Change the warn() function so that it recognises sentinels in the format
string. So this:
warn("format not a string literal...")
becomes
warn("~format-not-literal~format not a string literal...")
Then accept command line switches of the form:
-W-format-not-literal
to suppress this warning. All worked out at runtime: the warn()
function would have to run through the list of "-W-" arguments prior to
generating the warning.
* It's seamless: it is not required that _all_ instances of warn() be
changed on day one.
* Could be extended to allow/suppress -Werror on particular warnings
rather than on all of them.
* Documentation can be easily extracted direct from the source tree.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic