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]

No warning with uninitialised reference...


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();
};


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