Bug ID: 77958
           Summary: printf format checking -vs- variadic template
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot
          Reporter: tromey at gcc dot
  Target Milestone: ---

Consider this test case, derived from code I found in firefox:

#include <stdio.h>
#include <stdarg.h>

template<typename... Args>
static void
// __attribute__ ((format (printf, 1, 2)))
whatever(const char *fmt, Args&&... args)
  printf(fmt, args...);

void qq()
  whatever("hi %d", "bob");

If I compile this with -Wformat, I don't get any warnings.

However, if I uncomment the __attribute__, I get:

pokyo. g++ -Wall -c -Wformat In substitution of ‘template<class ... Args> void whatever(const char*,
Args&& ...) [with Args = {const char (&)[4]}]’:   required from here error: args to be formatted is not ‘...’
 whatever(const char *fmt, Args&&... args)

I think the attribute approach ought to work.

Reply via email to