https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86102

            Bug ID: 86102
           Summary: Include argument name in warning
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jg at jguk dot org
  Target Milestone: ---

Could GCC list the parameter name please?

Current output
$ gcc -O2 -Wall -Wextra -Wpedantic -o main main.c
main.c: In function ‘main’:
main.c:9:12: warning: format ‘%zu’ expects argument of type ‘size_t’, but
argument 3 has type ‘char *’ [-Wformat=]
     printf("result: %zu %zu %zu\n", value, "test", str);
            ^
main.c:9:12: warning: format ‘%zu’ expects argument of type ‘size_t’, but
argument 4 has type ‘char *’ [-Wformat=]

Improved output:
$ gcc -O2 -Wall -Wextra -Wpedantic -o main main.c
main.c: In function ‘main’:
main.c:9:12: warning: format ‘%zu’ expects argument of type ‘size_t’, but
argument 3 '"test"' has type ‘char *’ [-Wformat=]
     printf("result: %zu %zu %zu\n", value, "test", str);
            ^
main.c:9:12: warning: format ‘%zu’ expects argument of type ‘size_t’, but
argument 4 'str' has type ‘char *’ [-Wformat=]


This example as a string-litteral (as I believe it is called) in arg 3, and a
char* pointer as arg 4.



//gcc -O2 -Wall -Wextra -Wpedantic -o main main.c

#include <stdio.h>

int main (void)
{
    size_t value = 0;
    char * str = "other";
    printf("result: %zu %zu %zu\n", value, "test", str);

    return 0;
}

Reply via email to