Re: 2.6.14 assorted warnings

From: Stephen Rothwell
Date: Sun Oct 30 2005 - 17:55:16 EST


Also, this test case:

------------------------------------------------------------
extern int f1(void);

static unsigned char f2(unsigned int *def)
{
if (!f1())
return 0;
*def = 1;
return 1;
}

unsigned char f3(unsigned char **eoc)
{
unsigned int def;

if (!f2(&def))
return 0;
if (def)
*eoc = (unsigned char *)1;
else
*eoc = 0;
return 1;
}

static int f4(unsigned int *def)
{
if (!f1())
return 0;
*def = 1;
return 1;
}

unsigned char f5(unsigned char **eoc)
{
unsigned int def;

if (!f4(&def))
return 0;
if (def)
*eoc = (unsigned char *)1;
else
*eoc = 0;
return 1;
}
------------------------------------------------------------

compiled with "gcc -Wall -O2" gives:
xx.c: In function 'f3':
xx.c:14: warning: 'def' may be used uninitialized in this function

but doesn't complain about the same code in f5. The difference is that
f4 returns "int" while f2 returns "unsigned char". This has apparently
been fixed in gcc mainline - the above comes from Debian unstables' gcc
(4.0.3 20051023 (prerelease) (Debian 4.0.2-3)).

Compiling with "gcc -Wall -O2 -fnoinline" suppresses the warning.

--
Cheers,
Stephen Rothwell sfr@xxxxxxxxxxxxxxxx
http://www.canb.auug.org.au/~sfr/

Attachment: pgp00000.pgp
Description: PGP signature