Hi
The following code gives me a mystical warning when compiled with Level
4 (/W4) warnings on in VisualStudio .NET 2003.
I cant understande why.
Tested it with Comeau online (http://www.comeaucomputing.com/tryitout/)
and it gives me no warnings.
Can someone explain this ???
/David
typedef unsigned char BYTE;
typedef unsigned short WORD;
int main()
{
WORD Checksum1=0;
WORD Checksum2=0;
BYTE* Buffer=new BYTE[10];
for (int i=0; i!=10; ++i)
{
Buffer[i]=4;
}
for (int i=0; i!=10; ++i)
{
Checksum1+=Buffer[i]; // warning
Checksum2=Checksum2+Buffer[i]; // OK
}
}
warning C4244: '+=' : conversion from 'int' to 'WORD', possible loss of data