This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/25992] conditional expression and strings literal



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]