[Bug c/57137] spurious "format string is not literal" when the format string is marked with __attribute__((format))

2016-04-22 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57137

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-04-22
 CC||msebor at gcc dot gnu.org
 Ever confirmed|0   |1
  Known to fail||4.9.3, 5.3.0, 6.0

--- Comment #6 from Martin Sebor  ---
Confirmed.  In addition, as the example below illustrates, the warning in this
case is issued for the call where it could be avoided (in function g) and not
for the call that should be diagnosed (in function h).

$ cat v.c && gcc -S -Wformat -Wformat-nonliteral v.c
void f (const char*, ...) __attribute__ ((format (printf, 1, 2)));

void g (const char*) __attribute__ ((format (printf, 1, 0)));
void g (const char *fmt)
{
  f (fmt, "xxx");
}

void h (const char *fmt)
{
  g (fmt);
}
v.c: In function ‘g’:
v.c:6:3: warning: format not a string literal, argument types not checked
[-Wformat-nonliteral]
   f (fmt, "xxx");
   ^

[Bug c/57137] spurious format string is not literal when the format string is marked with __attribute__((format))

2013-05-01 Thread zbyszek at in dot waw.pl

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

--- Comment #1 from Zbigniew Jędrzejewski-Szmek zbyszek at in dot waw.pl 
2013-05-01 16:20:52 UTC ---
Created attachment 29988
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=29988
preprocessed example

[Bug c/57137] spurious format string is not literal when the format string is marked with __attribute__((format))

2013-05-01 Thread zbyszek at in dot waw.pl

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

--- Comment #2 from Zbigniew Jędrzejewski-Szmek zbyszek at in dot waw.pl 
2013-05-01 16:22:08 UTC ---
Forgot to specify gcc version:
gcc-4.8.0-2.fc19.x86_64

[Bug c/57137] spurious format string is not literal when the format string is marked with __attribute__((format))

2013-05-01 Thread zbyszek at in dot waw.pl

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

--- Comment #3 from Zbigniew Jędrzejewski-Szmek zbyszek at in dot waw.pl 
2013-05-01 16:24:32 UTC ---
Created attachment 29989
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=29989
minimal example

[Bug c/57137] spurious format string is not literal when the format string is marked with __attribute__((format))

2013-05-01 Thread pinskia at gcc dot gnu.org


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



--- Comment #4 from Andrew Pinski pinskia at gcc dot gnu.org 2013-05-01 
18:00:31 UTC ---

What options are you using when calling gcc?


[Bug c/57137] spurious format string is not literal when the format string is marked with __attribute__((format))

2013-05-01 Thread zbyszek at in dot waw.pl

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

--- Comment #5 from Zbigniew Jędrzejewski-Szmek zbyszek at in dot waw.pl 
2013-05-02 02:02:18 UTC ---
(In reply to comment #4)
 What options are you using when calling gcc?

Ah, I had it copied but forgot to paste...

gcc -pipe -Wall -Wextra -Wno-inline -Wundef -Wformat=2 -Wformat-security
-Wformat-nonliteral -Wlogical-op -Wsign-compare -Wmissing-include-dirs
-Wold-style-definition -Wpointer-arith -Winit-self
-Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes
-Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn
-Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings
-Wno-long-long -Wno-overlength-strings -Wno-unused-parameter
-Wno-missing-field-initializers -Wno-unused-result -Werror=overflow -ffast-math
-fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden
-ffunction-sections -fdata-sections -fstack-protector --param=ssp-buffer-size=4
-I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include   -pthread -O0 -g -c
unit.c -save-temps

or simpler:

gcc -Wformat-nonliteral -Wformat=2  -c unit.c -save-temps