Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site kobold.UUCP Path: utzoo!linus!security!genrad!grkermit!masscomp!kobold!tjt From: tjt@kobold.UUCP (T.J.Teixeira) Newsgroups: net.lang.c Subject: Re: Must useless expressions be evaluated? Message-ID: <169@kobold.UUCP> Date: Mon, 17-Oct-83 10:59:29 EDT Article-I.D.: kobold.169 Posted: Mon Oct 17 10:59:29 1983 Date-Received: Tue, 18-Oct-83 04:13:02 EDT References: <818@mit-eddie.UUCP> Organization: Masscomp, Littleton, MA Lines: 26 As others have pointed out, dereferencing a pointer might generate an illegal memory reference. Since this could generate a signal which could be caught by the program, the side effect of the dereferencing should be visible to the program. One might even go so far as to say that using computation time is a side effect. If the program has access to a cpu-time clock (i.e. times(II) in UNIX) (or less reliably, just a real-time clock) you could write a program for a particular machine that depends on the side effect of the execution time. Although very few programs rely on these side effects, benchmark programs are an important example. How many benchmarks have you seen that compute some numbers and then just throw them away? If you don't even print them out, a compiler could just decide to optimize your program to nothing! I believe that something like this actually did happen several years ago in somebodys us vs. them ads: the ratio between the execution times was something like 100000. I believe that the particular example was supposed to be a FORTRAN program with lots and lots of GOTO's. The intention was to determine how fast the machine could execute a branch instruction. However, one of the compilers just unravelled the branches and threw them all away, leading to the astronomically better apparent performance.