This is the mail archive of the gcc@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]

Re: string is const char [] ?


| Here is a real bug in egcs:
| 
| void f(      char *) {}
| voif f(const char *) {}
| 
| f("test not const"); // error in egcs. f(const char *) must be called,
|                      // because the type of string literals now is
|                      // array of n const char. However egcs calls
|                      // f(char*). -Wwrite-strings has no effect.
|                      // And even warning is surpressed.
| 
| Oleg.

Shouldn't this be added as a test in the testsuite?

Carlo

----

PS

~>/usr/src/egcs/egcs-cvs-objdir/gcc/g++ -B/usr/src/egcs/egcs-cvs-objdir/gcc/ -I/usr/src/egcs/egcs-cvs/libstdc++ -I/usr/src/egcs/egcs-cvs/libio -static -L/usr/src/egcs/egcs-cvs-objdir/libraries/libstdc++ -Wwrite-strings tst.cc
~>a.out
      char *
~>cat tst.cc
#include <iostream>

void f(      char *) { cout << "      char *" << endl; }
void f(const char *) { cout << "const char *" << endl; }
int main(void) { f("test not const"); }



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