c++/96
ao@infinet.com
ao@infinet.com
Sun Apr 1 00:00:00 GMT 2001
The following reply was made to PR c++/96; it has been noted by GNATS.
From: ao@infinet.com
To: gdr@gcc.gnu.org
Cc: gcc-gnats@gcc.gnu.org, martin@loewis.home.cs.tu-berlin.de,
nobody@gcc.gnu.org
Subject: Re: c++/96
Date: Fri, 16 Feb 2001 23:43:30 -0500 (EST)
>
> Synopsis: No warning with uninitialised reference...
>
> Responsible-Changed-From-To: unassigned->gdr
> Responsible-Changed-By: gdr
> Responsible-Changed-When: Thu Feb 15 04:21:06 2001
> Responsible-Changed-Why:
> Analysed
> State-Changed-From-To: analyzed->closed
> State-Changed-By: gdr
> State-Changed-When: Thu Feb 15 04:21:06 2001
> State-Changed-Why:
> Hi,
>
> This is not a bug in the compiler. It is just the way C/C++
> works: Just after `bar& var', the name 'var' is in scope and
> can serve to initialize itself. It is just that referencing it later
> will cause undefined behaviour.
Ok, so when it is used later, why is there no message similar to the
"variable used may not be initialised" one you get in other circumstances.
I notice too that:
void y(int);
int foo (int x)
{
int a = a;
y(a);
return x;
}
compiles without warning (same as my initial report).
Regardless of how C/C++ works, surely this construct deserves a
warning of sorts (or at least a warning that can be turned on?)
Regards,
/Mike
More information about the Gcc-prs
mailing list