Wformat-security and string literal

Hagen Paul Pfeifer hppgccml@0xdef.net
Mon Oct 17 10:25:00 GMT 2005


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



More information about the Gcc mailing list