[Bug c++/25992] conditional expression and strings literal
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25992 Paolo Carlini paolo.carlini at oracle dot com changed: What|Removed |Added Status|NEW |ASSIGNED CC|anton.kirillov@rd-software. | |com, gcc-bugs at gcc dot gnu.org | Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com --- Comment #6 from Paolo Carlini paolo.carlini at oracle dot com --- Mine.
[Bug c++/25992] conditional expression and strings literal
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25992 Paolo Carlini paolo.carlini at oracle dot com changed: What|Removed |Added Status|ASSIGNED|NEW Assignee|paolo.carlini at oracle dot com|unassigned at gcc dot gnu.org
[Bug c++/25992] conditional expression and strings literal
--- Comment #5 from bangerth at dealii dot org 2006-03-08 05:02 --- Confirmed. These two lines should behave the same, but don't: -- extern bool flag; int main() { char* p; p = (true ? a : lalala ); p = (flag ? a : lalala ); } -- g/x /home/bangerth/bin/gcc-4.2*/bin/c++ -c x.cc -Wwrite-strings x.cc: In function #8216;int main()#8217;: x.cc:5: warning: deprecated conversion from string constant to #8216;char*#8217;' x.cc:6: error: invalid conversion from #8216;const char*#8217; to #8216;char*#8217; W. -- bangerth at dealii dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Keywords||diagnostic Last reconfirmed|-00-00 00:00:00 |2006-03-08 05:02:36 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25992
[Bug c++/25992] conditional expression and strings literal
--- Comment #1 from pinskia at gcc dot gnu dot org 2006-01-27 12:39 --- earth:~g++ t.cc -pedantic -Wwrite-strings t.cc: In function int main(): t.cc:5: warning: deprecated conversion from string constant to char*' -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25992
[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
[Bug c++/25992] conditional expression and strings literal
--- Comment #4 from anton dot kirillov at rd-software dot com 2006-01-27 14:20 --- (In reply to comment #3) I have not looked into the standard yet but if GCC's warning message is correct this is valid but deprecated code which allows for a compiler to accept it or not. deprecated this converiont: void foo( char* ) { } int main() { foo( lalala ); } i.e. convresion from strings literal to char*, but the result of expression (0 ? a : b) IS NOT STRING LITERAL!!! IT'S CONST CHAR[2]!!! ( See 5.16 ) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25992
[Bug c++/25992] conditional expression and strings literal
--- Comment #3 from pinskia at gcc dot gnu dot org 2006-01-27 13:59 --- I have not looked into the standard yet but if GCC's warning message is correct this is valid but deprecated code which allows for a compiler to accept it or not. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25992