This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/25992] conditional expression and strings literal
- From: "anton dot kirillov at rd-software dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jan 2006 13:12:32 -0000
- Subject: [Bug c++/25992] conditional expression and strings literal
- References: <bug-25992-12082@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from anton dot kirillov at rd-software dot com 2006-01-27 13:12 -------
(In reply to comment #1)
> earth:~>g++ t.cc -pedantic -Wwrite-strings
> t.cc: In function ?int main()?:
> t.cc:5: warning: deprecated conversion from string constant to ?char*?'
>
Conversion from string constant to ?char*?' it's legacy from C, but GCC should
not perceive it as const char*, because the type of expression is const char[]!
I think GCC have defined it as a compile-time constant, but it's infeasible
solution.
In other situation it behaves correctly:
void foo( char* );
int main()
{
bool flag = false;
foo( flag ? "a" : "b" ); // error ( cannot convert from const char* to
char* )
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25992