This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Format attribute doesn't work on methods
- To: egcs-bugs at cygnus dot com
- Subject: Format attribute doesn't work on methods
- From: David Mazieres <dm at reeducation-labor dot lcs dot mit dot edu>
- Date: Tue, 1 Dec 1998 18:03:32 -0500 (EST)
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);
}