questions from using lint
Chris Torek
chris at umcp-cs.UUCP
Thu May 15 18:31:30 AEST 1986
In article <640 at bunkerb.UUCP> garys at bunkerb.UUCP (Gary M. Samuelson) writes:
>If I say "a = b", I have clearly used the value of the expression.
Which expression? `b', certainly, but what about the value of `a = b'?
The problem is that there really are several `kinds' of expressions
in C. All expressions have values; but some are more useful than
others. The following are grouped into `error' and `non-error'
classes:
Error: Non-Error:
open("foo", 1); strcpy(hold, s);
a + 1; a++;
My best guess at the moment at the `true' distinction between the
`error' and `non-error' classes is that the latter `end' in side
effects. The return value from `open' is usually as important as
its side effect; but that from strcpy() is often not. `a + 1'
has no side effects in most cases (one where it might is if integer
overflow traps are enabled); `a++' has a clear side effect.
So perhaps lint needs, in addition to /*VARARGS*/ and /*ARGSUSED*/,
and the System V style /*PRINTFLIKE*/, another pragma: /*FORSIDEEFFECTS*/.
Routines like strcpy(), strcat(), and perhaps even close(), would be
so declared in llib-lc. This would tell lint that the return value,
though available, was purely for convenience: that the function is
normally called simply for its side effects.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP: seismo!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at mimsy.umd.edu
More information about the Comp.lang.c
mailing list