This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]