This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21509] New: [3.3 regression] -Wformat=2 incorrectly warns about string literalness
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 May 2005 09:53:28 -0000
- Subject: [Bug c++/21509] New: [3.3 regression] -Wformat=2 incorrectly warns about string literalness
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider
#include <stdio.h>
void foo(int i)
{
printf("Hello World %d!\n", i);
printf(&"Hello World %d!\n"[0], i);
printf(&"Hello World %d!\n"[6], i);
}
> g++-3.3 -c c-format.C -Wformat=2
> g++-3.4 -c c-format.C -Wformat=2
c-format.C: In function `void foo(int)':
c-format.C:6: warning: format not a string literal, argument types not checked
> g++-4.0 -c c-format.C -Wformat=2
c-format.C: In function 'void foo(int)':
c-format.C:6: warning: format not a string literal, argument types not checked
c-format.C:7: warning: format not a string literal, argument types not checked
> g++-4.1 -c c-format.C -Wformat=2
c-format.C: In function 'void foo(int)':
c-format.C:6: warning: format not a string literal, argument types not checked
c-format.C:7: warning: format not a string literal, argument types not checked
so we're getting worse here. The problem is that c-format.c:check_format_arg
does not handle string literals of the form ADDR_EXPR (ARRAY_REF ( ... )).
This blocks changing the C frontend to emit &a[0] for array-to-pointer decay.
--
Summary: [3.3 regression] -Wformat=2 incorrectly warns about
string literalness
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rguenth at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21509