This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/39438] Can't compile a wrapper around strftime with -Werror=format-nonliteral


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39438

Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #5 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
Could you produce a complete testcase that (In reply to D. Hugh Redelmeier from
comment #4)
> I have this problem too.  I'm writing a wrapper for strftime.  I get a
> warning on the actual strftime call.  
> 
> warning: format not a string literal, format string not checked
> [-Wformat-nonliteral]
>   strftime(buf, buflen, fmt, t);
> 
> Surely GCC should not that for "fmt" argument has been checked to be a valid
> strftime format at the points where prettynow gets called.  So there is no
> need to whine that it is unchecked.
> 

You should be able to produce a minimal self-contained testcase (the one you
posted doesn't compile). See http://gcc.gnu.org/bugs/minimize.html
The best would be to include only the definitions of the types that you need
and declare as 'extern' library functions that you use to avoid including
headers.

If you can produce another similar example that works with printf, that would
also help.

The second step would be to find out why it works with printf and not with
strftime, but that would require debugging GCC while compiling your (new)
testcases, so saving the first step will make it more likely that someone will
do the second.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]