inconsistent behavior with string literals and char*

Corey Kosak kosak@cs.cmu.edu
Sun Oct 31 23:03:00 GMT 1999


Surely lines 7 and 8 should either both be legal, or both illegal.

% cat qwe.cc && g++ -v && g++ qwe.cc
const int x=0;
int y;

int main()
{
  char *p="moo";
  char *q= x>1 ? "moo" : "cow";  //line 7
  char *r= y>1 ? "moo" : "cow";  //line 8
  return 0;
}
Reading specs from /usr/local/libexec/gcc-19991013/lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 19991013 (experimental)
qwe.cc: In function `int main ()':
qwe.cc:8: cannot convert `const char *' to `char *' in initialization
% 



More information about the Gcc-bugs mailing list