This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Wformat-security and string literal
- From: Hagen Paul Pfeifer <hppgccml at 0xdef dot net>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 17 Oct 2005 11:49:05 +0200
- Subject: Wformat-security and string literal
Following code generate a _dubious_ warning message:
int main(void) {
const char * const literal = "xxx";
fprintf(stderr, literal);
return 0;
}
cc -Wall -Wformat-security -o main main.c
main.c: In function `main':
main.c:9: warning: format not a string literal and no format arguments
check_format_info() in gcc/c-format.c doesn't check if the format
argument is a _pointer_ to a string literal.
best regards
HGN