Internal compiler error in egcs-2.90.29 980515 (egcs-1.0.3 release)

Dave Steffen steffend@glitch.physics.colostate.edu
Wed Jun 3 16:21:00 GMT 1998


Hi Folks,

   I've been bumbling around with a switchable ostream wrapper -
   something with a switch that determines whether or not it really
   outputs anything.

   I'm _NOT_ claiming that the following is good - or even legitimate
   - code. But it generates an internal error, which egcs shouldn't
     do.


ec++ -ansi -Wall   -I/opt/egcs/contrib/TNT -I/opt/egcs/contrib/Dave -I/opt/egcs/contrib/libg++ -c switchstream.C
switchstream.C:26: Internal compiler error.
switchstream.C:26: Please submit a full bug report to `egcs-bugs@cygnus.com'.
gmake: *** [switchstream.o] Error 1

here's the code (and BTW, and suggestions are welcome ;-)

#include <iostream.h>
class switch_stream 
{
public:

  bool on;
  ostream* out;

  switch_stream (ostream& o)
    {
      out = &o;
      on = true;
    }
  
  bool output(bool b)
    {
      on = b;
      return on;
    }
};

template <class T> 
ostream& operator<<<T> (switch_stream& s, T& thing)
{
  if (s.on)
    *(s.out) << thing;
  return *(s.out);
}

  

int main()
{
  switch_stream sout (cout);
  sout.output(true);  
  sout << "you should see this" << endl;
  sout.output(false);
  sout << "but not this" << endl;
}

THANKS!!





More information about the Gcc-bugs mailing list