#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int i,
j = 0;
for (i = 3; i >> j++; --i) {
printf("%d\t", '-' << j);
printf("%d\t", '-' - '/' << j);
printf("%d\t", '-' - '-' / '/' << j);
printf("%d\t", '-' - '-' - '/' / '/' << j);
puts("");
}
printf("\n %d", '-');
printf("\n %d", '-' - '/');
printf("\n%d", '-' - '-' / '/');
puts("");
return (EXIT_SUCCESS);
}
/*
Splint output:
foo.c: (in function main)
foo.c(13,23): Right operand of >> may be negative (int): i >> j++
The right operand to a shift operator may be negative (behavior
undefined).
(Use -shiftnegative to inhibit warning)
foo.c(13,17): Left operand of >> may be negative (int): i >> j++
The left operand to a shift operator may be negative (behavior is
implementation-defined). (Use -shiftimplementation to inhibit
warning)
foo.c(13,17): Test expression for for not boolean, type int: i >> j++
Test expression type is not boolean or int. (Use -predboolint to
inhibit
warning)
foo.c(16,31): Right operand of << may be negative (int): '-' << j
foo.c(16,24): Left operand of << may be negative (char): '-' << j
foo.c(16,24): Format argument 1 to printf (%d) expects int gets char:
'-' << j
To make char and int types equivalent, use +charint.
foo.c(16,18): Corresponding format code
foo.c(17,37): Right operand of << may be negative (int): '-' - '/' <<
j
foo.c(17,24): Left operand of << may be negative (char): '-' - '/' <<
j
foo.c(17,24): Format argument 1 to printf (%d) expects int gets char:
'-' - '/' << j
foo.c(17,18): Corresponding format code
foo.c(18,43): Right operand of << may be negative (int): '-' - '-' /
'/' << j
foo.c(18,24): Left operand of << may be negative (char): '-' - '-' /
'/' << j
foo.c(18,24): Format argument 1 to printf (%d) expects int gets char:
'-' - '-' / '/' << j
foo.c(18,18): Corresponding format code
foo.c(19,49): Right operand of << may be negative (int):
'-' - '-' - '/' / '/' << j
foo.c(19,24): Left operand of << may be negative (char):
'-' - '-' - '/' / '/' << j
foo.c(19,24): Format argument 1 to printf (%d) expects int gets char:
'-' - '-' - '/' / '/' << j
foo.c(19,18): Corresponding format code
foo.c(22,9): Return value (type int) ignored: puts("")
Result returned by function call is not used. If this is intended,
can cast
result to (void) to eliminate message. (Use -retvalint to inhibit
warning)
foo.c(28,21): Format argument 1 to printf (%d) expects int gets char:
'-'
A character constant is used as an int. Use +charintliteral to allow
character constants to be used as ints. (This is safe since the
actual type
of a char constant is int.)
foo.c(28,17): Corresponding format code
foo.c(29,21): Format argument 1 to printf (%d) expects int gets char:
'-' - '/'
foo.c(29,17): Corresponding format code
foo.c(30,20): Format argument 1 to printf (%d) expects int gets char:
'-' - '-' / '/'
foo.c(30,16): Corresponding format code
foo.c(33,5): Return value (type int) ignored: puts("")
Lint output:
--- Module: foo.c (C)
_
for (i = 3; i >> j++; --i) {
foo.c(13) : Info 702: Shift right of signed quantity (int)
_
printf("%d\t", '-' - '/' << j);
foo.c(17) : Info 701: Shift left of signed quantity (int)
foo.c(17) : Warning 504: Unusual shift operation (left side
unparenthesized)
_
printf("%d\t", '-' - '-' / '/' << j);
foo.c(18) : Warning 504: Unusual shift operation (left side
unparenthesized)
_
printf("%d\t", '-' - '-' - '/' / '/' << j);
foo.c(19) : Info 834: Operator '-' followed by operator '-' is
confusing. Use
parentheses.
foo.c(19) : Info 778: Constant expression evaluates to 0 in operation
'-'
foo.c(19) : Info 701: Shift left of signed quantity (int)
foo.c(19) : Warning 504: Unusual shift operation (left side
unparenthesized)
*/
/*
The expression:
'-' - '-'
is zero, of course, and so it is not very interesting.
*/