On Fri, 13 Jul 2007 06:23:18 +0000, Richard Bos wrote:
Army1987 <ar******@NOSPAM.itwrote:
>['A' has type int]
Incredible! Splint 3.1.1:
test.c:77:27: Operands of != have incompatible types (int, char):
getchar() != '\n'
Then Splint is, quite simply, wrong.
>But wait a moment...
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.)
It does know that '\n' has type int, but it chooses to ignore
that!
>(Right above that I read:
test.c:77:12: Operand of ! is non-boolean (int): !feof(stdin)
The operand of a boolean operator is not a boolean. Use +ptrnegate to allow !
to be used on pointers. (Use -boolops to inhibit warning)
Should I throw this program in the trash?)
Yes. Both those warnings are entirely spurious.
Or perhaps - I don't know Splint - you should turn off C++ mode. If
you're in C++ mode, that would explain at least the first warning, and
possibly - I don't know C++ this precisely, either, but it _is_ stricter
than C where type conversions are involved - the second. Never use any
program's C++ mode when you're handling C code.
I don't think so, its manpage doesn't even mention C++, and the
file extension was .c. And I read:
-standard
The default mode. All checking done by weak, plus modifies check-
ing, global alias checking, use all parameters, using released
storage, ignored return values or any type, macro checking,
unreachable code, infinite loops, and fall-through cases. The
types bool, int and char are distinct. Old style declarations
are reported.
-checks
Moderately strict checking. All checking done by standard, plus
must modification checking, rep exposure, return alias, memory
management and complete interfaces.
-strict
Absurdly strict checking. All checking done by checks, plus modi-
fications and global variables used in unspecified functions,
strict standard library, and strict typing of C operators. A spe-
cial reward will be presented to the first person to produce a
real program that produces no errors with strict checking.
Considering it gave 22 warnings in a 121-line source file, even
after I fixed all the useful and relevant ones, (some of these are
useful in some situations but not in the one I had, and I didn't
feel like polluting my code with /*@iknowwhatiamdoing@*/ comments
and (void)fprintf(stderr, "What would I be supposed to do if this"
" failed?\n" casts), and I was using the default mode, I will not
dare to imagine what the -strict mode does...
--
Army1987 (Replace "NOSPAM" with "email")
"Never attribute to malice that which can be adequately explained
by stupidity." -- R. J. Hanlon (?)