No warning with uninitialised reference...

ao@infinet.com ao@infinet.com
Fri Mar 10 12:46:00 GMT 2000


Hi,

The following code fails to give a warning about using an uninitialised
reference. While the code is obviously incorrect, this cost me a lot of
time trying to debug a crashing server. Please note that I am not at all
being critical of the work done on gcc, but I would like to note that an
error such as this is very difficult to track until you actually notice
the incorrect code...

Regards,

/Mike

---------------------------------------------------------------------------

class foo
{
public:

  virtual void fn();
};

class bar : public foo
{
public:

  virtual void fn();
  int fn2();
};

int bug_fn(foo& x)
{
  bar& var = dynamic_cast<bar&>(var);	// <-- the second "var" should be "x"
  return var.fn2();
};



More information about the Gcc-bugs mailing list