Download Compilation Systems Volume 1 (Tools)

Transcript
Compilation Systems Volume 1 (Tools)
1
int f()
2
{
3
int a[10];
4
return a[5 * 2 / 10 - 2];
5
}
============
(4) warning: array subscript cannot be negative: -1
assignment causes implicit narrowing conversion
10
Format: Compound
An object was assigned to one of a smaller type. Invoking lint with -a suppresses the
message. So does an explicit cast to the smaller type.
1
void fun()
2
{
3
short s;
4
long l = 0;
5
s = l;
6
}
============
assignment causes implicit narrowing conversion
(5)
assignment of negative constant to unsigned type
10
Format: Simple
A negative constant was assigned to a variable of unsigned type. Use a cast or the U
suffix.
1
void fun()
2
{
3
unsigned i;
4
i = -1;
5
i = -1U;
6
i = (unsigned) (-4 + 3);
7
}
============
(4) warning: assignment of negative constant to unsigned
type
assignment operator ?=? found where ?==? was expected
Format: Simple
10-14
10