Re: [PATCH] *(int*)0 = 0 & variations

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Tue, 29 Jun 1999 18:13:56 +0200


Stefan Monnier wrote:
> Oh, yes it does: the compiler cannot always prove the code to be side-effect
> free, else

Sure, but almost all assertions are really simple tests, expressions
like `a != (b & FLAG_BIT) && (b != (b & OTHER_FLAG)' and so on. Those
are trivially side-effect free: there are no assignments or function
calls. The compiler can prove they're dead code.

There are more complicated assertions but I happen to think they're
either (a) rare, or (b) calls to consistency-checking functions which
can be stubbed for non-debug code anyway.

> the same analysis could be used to warn of improper use of assert.

It already detects when you have an expression with no side effects, and
can warn about it. It'd be nice to be able to reverse that -- get a
warning when an expression has side effects that it shouldn't.
Sometimes it would be wrong, just like it is for "use of uninitialised
variable", but that's not a terrible thing.

-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/