This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: unitialised error
- From: llewelly at xmission dot com
- To: Ken Foskey <foskey at optushome dot com dot au>
- Cc: gcc help <gcc-help at gcc dot gnu dot org>
- Date: 01 Jul 2004 10:22:12 -0600
- Subject: Re: unitialised error
- References: <1088683544.25475.15.camel@froddo.foskey.org.au>
Ken Foskey <foskey@optushome.com.au> writes:
> The following code gives me an uninitialised warning on nCol. There is
> no possible default clause for this one.
>
> switch( nXIndex & 3 )
> {
> case 0 :
> nCol = *pTmp >> 6;
> break;
> case 1 :
> nCol = ( *pTmp >> 4 ) & 0x03 ;
> break;
>
> case 2 :
> nCol = ( *pTmp >> 2 ) & 0x03;
> break;
> case 3 :
> nCol = ( *pTmp++ ) & 0x03;
> break;
> }
What version of gcc are you using? I don't get any such warning for this
code with gcc 2.95.3, 3.3.3 or 3.4 .
I completed it like this:
int main()
{
int nXIndex;
int nCol;
int Tmp;
int *pTmp;
switch( nXIndex & 3 )
{
case 0 :
nCol = *pTmp >> 6;
break;
case 1 :
nCol = ( *pTmp >> 4 ) & 0x03 ;
break;
case 2 :
nCol = ( *pTmp >> 2 ) & 0x03;
break;
case 3 :
nCol = ( *pTmp++ ) & 0x03;
break;
}
Tmp= nCol;
}