This is the mail archive of the gcc@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]
Other format: [Raw text]

Missing warning?


I think the following program should produce some kind of warning
(probably "warning: `x' might be used uninitialized in this function")

extern void bar(void *);

int main(void)
{
        void *x = x;
        bar(x);
        return 0;
}

If the initialisation of x is separated out as:

int main(void)
{
        void *x;
        x = x;
        bar(x);
        return 0;
}

then GCC does warn about use of an uninitialised variable.  This behaviour
is constant across gcc 2.95, 3.0 and 3.2.  I guess it's possible that this
behaviour is required by the C spec, but it seems a little unreasonable
to me.

-- 
Revolutions do not require corporate support.


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