Bug 33588 - gcc warns of (char*) conversion on client-side varargs funcs
Summary: gcc warns of (char*) conversion on client-side varargs funcs
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-29 16:29 UTC by stephan beal
Modified: 2007-11-13 23:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Demonstrates the problem. (350 bytes, text/plain)
2007-09-29 16:31 UTC, stephan beal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description stephan beal 2007-09-29 16:29:32 UTC
(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).
Comment 1 stephan beal 2007-09-29 16:31:49 UTC
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++
Comment 2 Andrew Pinski 2007-09-29 18:04:03 UTC
va_list on the target you are using just happens to be a char* and not a seperate type.
Comment 3 Manuel López-Ibáñez 2007-11-13 05:19:25 UTC
(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?
Comment 4 Andrew Pinski 2007-11-13 22:54:59 UTC
(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.
Comment 5 Manuel López-Ibáñez 2007-11-13 23:20:35 UTC
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.