This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
No warning with uninitialised reference...
- To: gcc-bugs at gcc dot gnu dot org
- Subject: No warning with uninitialised reference...
- From: ao at infinet dot com
- Date: Fri, 10 Mar 2000 15:44:12 -0500 (EST)
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();
};