[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Why does potato compiling suck?

On Sun, 5 Dec 1999, Ben Hendrickson wrote:

> $ echo " 
> void f (const char *& str) {}
> void main ()
> { 
> 	char *s;
> 	f(s);
> }
> " > s.cpp
> $ g++ s.cpp -o s.o
> s.cpp: in function `int main(...)':
> s.cpp:7: initalizing non-const `const char *&' with `char *' will use a
> temporary 
> s.cpp:2: in passing argument 1 of `f(const char *&)'

const char *Boink = "foo";
void f(const char *& str) {str = Boink;}
void main()
   char *s;
   f[0] = 0;

This is a very grevious error, particularly considering that newer gccs
put compiler strings in read only memory. 

> The author should have declared s to be const.  The compiler says it will
> use a temporary variable to work around this.  The compiler doesn't.
If it doesn't use a temorary then that is a compiler bug
I also don't think it should be fatal, temporary generation has always
been a warning thing, email the egcc people.


Reply to: