https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61861
Bug ID: 61861 Summary: Incorrect column number for -Wdiscarded-qualifiers Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com It seems that GCC outputs incorrect column number for "__FILE__", but not user defined macro "T". $: cat t.c extern int * f (int*a, char * loc); #define T "t.c" void g(int *a) { f(a, T); /*column number here is correct*/ f(a, __FILE__); /*column number here is INCORRECT*/ } $: $: gcc-trunk -Wwrite-strings -c t.c t.c: In function ‘g’: t.c:3:11: warning: passing argument 2 of ‘f’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] #define T "t.c" ^ t.c:6:8: note: in expansion of macro ‘T’ f(a, T); ^ t.c:1:14: note: expected ‘char *’ but argument is of type ‘const char *’ extern int * f (int*a, char * loc); ^ t.c:7:1: warning: passing argument 2 of ‘f’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] f(a, __FILE__); ^ t.c:1:14: note: expected ‘char *’ but argument is of type ‘const char *’ extern int * f (int*a, char * loc); ^ $: $: clang-trunk -Wwrite-strings -c t.c t.c:6:8: warning: passing 'const char [4]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] f(a, T); ^ t.c:3:11: note: expanded from macro 'T' #define T "t.c" ^~~~~ t.c:1:31: note: passing argument to parameter 'loc' here extern int * f (int*a, char * loc); ^ t.c:7:8: warning: passing 'const char [4]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] f(a, __FILE__); ^~~~~~~~ <scratch space>:2:1: note: expanded from here "t.c" ^~~~~ t.c:1:31: note: passing argument to parameter 'loc' here extern int * f (int*a, char * loc); ^ 2 warnings generated. $: