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]

Format attribute doesn't work on methods


The __attribute__ ((format)) argument does not seem to work on methods
in egcs (I have tried several versions).

The code below seems like it should generate 3 warning messages, but
it compiles without warning under c++ -Wall -Wformat.

Note that I am using (printf, 2, 3) rather than (printf, 1, 2) because
I'm assuming the hidden "this" argument counts as 1.  (printf, 1, 2)
causes complaints about argument 1 not being of type char *.

Thanks,
David


==

struct warnobj {
  warnobj (const char *, ...) __attribute__ ((format (printf, 2, 3)));
  void fmt (const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
  void operator() (const char *fmt, ...)
    __attribute__ ((format (printf, 2, 3)));
};

int
main ()
{
  warnobj w ("%s %s\n", "next arg is missing");
  w ("%d");
  w.fmt ("%x");
  exit (0);
}


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