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]

inconsistent behavior with string literals and char*



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
% 

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