This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: deprecated conversion from string constant to 'char *'
- From: Tim Prince <timothyprince at sbcglobal dot net>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Timothy C Prince <tprince at myrealbox dot com>, gcc-help at gcc dot gnu dot org
- Date: Thu, 06 Jul 2006 18:52:35 -0700
- Subject: Re: deprecated conversion from string constant to 'char *'
- References: <1152231213.c7d6bd1ctprince@myrealbox.com> <m3ejwy8dlv.fsf@localhost.localdomain>
- Reply-to: tprince at myrealbox dot com
Ian Lance Taylor wrote:
> "Timothy C Prince" <tprince@myrealbox.com> writes:
>
>> g++ 4.2 rejects a quoted string constant, where the function prototype has char *. It says warning, but the warning is fatal, even without -Werror. -fpermissive doesn't let it pass.
>>
>> info g++ lists an option -fconst-strings, but that option has been removed.
>>
>> What is expected as a replacement for current source code with 1000's of string constants, which up to now worked with char * prototype?
>
> This is what I get:
>
>> cat foo.cc
> extern void foo(char*);
> void bar() { foo("Hello"); }
>> g++ -c foo.cc
> foo.cc: In function ‘void bar()’:
> foo.cc:2: warning: deprecated conversion from string constant to ‘char*’'
>> echo $?
> 0
>
> Looks like a warning to me, not an error. Please give a small source
> code example and the command line you are using.
>
> Ian
>
>
I haven't figured out yet whether build is permitted to continue below
some small number of occurrences. If it requires a large number to make
it fatal, that example would not be small. In my case, no .o or a.out
is generated, either on ia64 or x86-64 linux.
A plurality of opinions I have gathered are in favor of allowing
constant strings under a prototype 'const char *', and allowing an
unlimited number of warnings, neither of which works with the current
g++ 4.2. That, or providing a minimum example, begins to look like a
PR, which might delay indefinitely any resolution.
I must check also whether such a warning can be obtained from other
compilers.
I am more interested in finding out what the g++ developers' intentions
are, what way they want the code changed, since they seem to be well set
on not permitting old code to run with minimal modification.
Thanks.