develooper Front page | perl.perl6.internals | Postings from August 2002

Re: [perl #15907] [PATCH] Make warnings configurable

From:
Juergen Boemmels
Date:
August 7, 2002 02:49
Subject:
Re: [perl #15907] [PATCH] Make warnings configurable
Message ID:
m27kj3f19c.fsf@helium.physik.uni-kl.de
Nicholas Clark <nick@ccl4.org> writes:

> On Mon, Aug 05, 2002 at 04:11:26PM -0700, Brent Dax wrote:
> > Jürgen Bömmels:
> > # The other warnings I found are a little bit more complicated
> > # - nonliteral formats in Parrot_vsprintf_s
> > 
> > If I understand what is meant by this warning, it's trying to warn about
> > the case where you accidentally forgot to give sprintf a format.  I can
> > assure you that this is no accident; just cast around it or whatever.

I understand what the warning means; my problem is finding a solution
for this issue. Just casting will not work. One possible solution
would be to write our custom print routine for floats as we already do
for ints. This way we get rid of the system sprintf entirly. But hey,
its just a warning. --ccwarn=-Wno-format-nonliteral also works.

> It's where the first argument to printf-like function isn't a literal
> string, and the compiler has been instructed to check that the arguments
> to printf-like functions correspond to the % format specifiers in the format
> string.  The compiler is warning that it's unable to make this check
> because the format isn't known at compile time, and I don't know of a
> solution.
> 
> (Annoyingly, gcc doesn't seem to come with pragmas to say "I acknowledge the
> next line does something that I've asked you to warn me about, so don't
> warn".

"Trust me, I know what I'm doing" -- Sledge Hammer
Just switching of the non-literal warning entirly does not harm the
format-checking where its possible (i.e. were the format is literal).

> I think we've still got the warnings from passing const pointers to
> free() and realloc(), and you can't (directly) cast them away.
> Although I believe that you can circumvent that warning about casting away
> const by using a union of void * and const void *, and laundering your
> const-ness away with it)

With a gcc 3.1 and -Werror -Wno-format-nonliteral I got no warnings
on an cvs tree from Monday. Now there are again some padding warnings
in jit.h. Is it reasonable to have -Wpadded in the default set of
warnings?

bye
juergen




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About