This is the mail archive of the
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>, gdr at integrable-solutions dot net, gcc-help at gcc dot gnu dot org
- Date: Fri, 07 Jul 2006 18:57:37 -0700
- Subject: Re: deprecated conversion from string constant to 'char *'
- References: <email@example.com> <firstname.lastname@example.org>
- Reply-to: tprince at myrealbox dot com
Ian Lance Taylor wrote:
"Timothy C Prince" <email@example.com> writes:Ian,
gcc built from last Saturday's post on gcc.gnu.org/pub/gcc/snapshots
I've seen remarks about that not being a reliable source for FSF gcc. If those aren't good to use, why not offer something better?
That is a reliable source for FSF gcc snapshots.
Of course snapshots are just that: a snapshot of the development in
progress. They are not guaranteed to work.
We still can't help with you without a complete and exact description
of precisely what you are doing.
The example you made up is good enough. As you can see from the
follow-ups, replacing 'char *' by 'const char *' in your example, or
(consistently throughout) in my own case, solve the problem. The
question remains whether g++ should abort the compilation when the
legacy source code is discovered. If it does abort, with no option to
continue (as it does in my testing), should it be reported as Error
rather than warning? Should g++ -m32 produce a diagnostic similar to
In case it's of interest, I've investigated the following compilers:
g++ 4.2 x86-64 reports "deprecated conversion" (and aborts) when const
g++ 4.2 -m32 x86-64, and Windows 32-bit, fail on a bunch of libstdc++
problems relative to char * conversions, when const is omitted
Intel icpc 9.1 linux x86-64 doesn't care whether const is present, no
warning available (consistent with g++ 4.0.2 as base installation)
Intel ICL 9.1 Windows x64 has STL problems when const is omitted (unable
to verify whether that corresponds to behavior of base MSVC++ installation)
MSVC 2003 toolkit 32-bit fails on excessive warnings without const, if
-Wall is set, otherwise accepts either version
So, I'm satisfied that 'const char *' is the correct solution, and that
no consistent treatment of legacy code (warning/abort/no warning/STL
failure) can be expected of current compilers.