(i submitted this via gccbugs, but the script gave me no feedback about whether the report was actually sent or not, so i'm re-posting here.)
gcc 4.2.1 appears to incorrectly(?) give a warning when a client-written varargs func is passed a string literal (e.g. __FILE__) as one of the arguments. e.g.
my_func( "format string: %s", __FILE__ )
warning: deprecated conversion from string constant to ‘char'
Curiously, the warning is not emitted when printf() is used.
This apparently bogus warning causes -Werror builds (that is, all of my builds) to fail.
i will attach a demo file after saving this bug (assuming bugzilla lets me, otherwise i'll paste it in as a comment).
Created attachment 14266 [details]
Demonstrates the problem.
Demonstrates this seeming bug, including the discrepancy between client-defined varargs funcs and built-ins. Compile with: gcc gcc-421-charptr.cpp -lstdc++
va_list on the target you are using just happens to be a char* and not a seperate type.
(In reply to comment #2)
> va_list on the target you are using just happens to be a char* and not a
> seperate type.
So? Is the warning warranted? Can be worked-around? Should GCC detect this case and not warn?
(In reply to comment #3)
> So? Is the warning warranted?
Yes because va_list is not a first class type and never was and is very ABI dependent.
> Can be worked-around?
Well no, because va_list's type is ABI dependent.
Stephan, please, try with
my_func( "format string: %s", (char *)__FILE__ )
Otherwise, you can use -Wno-write-strings to avoid the warning or -Wno-error=write-strings to get the warning as a warning even when using -Werror.