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

Timo Sirainen <tss at iki dot fi> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tss at iki dot fi

--- Comment #3 from Timo Sirainen <tss at iki dot fi> 2012-01-10 20:38:44 UTC ---
I ran into this as well. I tried two ways, neither of which works with strftime
(both work with printf):

static void __attribute__((format (strftime, 1, 0)))
test1(const char *fmt, const struct tm *tm)
{
    char buf[100];

    strftime(buf, sizeof(buf), fmt, tm);
}

static const char *__attribute__((format_arg (1)))
helper(const char *fmt)
{
    return fmt;
}

static void
test2(const char *fmt, const struct tm *tm)
{
    char buf[100];

    strftime(buf, sizeof(buf), helper(fmt), tm);
}


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