Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-lcc!ames!ucbcad!ucbvax!decvax!decwrl!hplabs!sdcrdcf!trwrb!aero!venera.isi.edu!lmiller From: lmiller@venera.isi.edu (Larry Miller) Newsgroups: comp.lang.c Subject: Re: C and restraints on optimization Message-ID: <2447@venera.isi.edu> Date: Mon, 13-Apr-87 10:58:58 EST Article-I.D.: venera.2447 Posted: Mon Apr 13 10:58:58 1987 Date-Received: Sun, 19-Apr-87 00:24:39 EST References: <15958@sun.uucp> <5716@brl-smoke.ARPA> <14680@cca.CCA.COM> <995@wanginst.EDU> <6264@mimsy.UUCP> Reply-To: lmiller@venera.isi.edu.UUCP (Larry Miller) Organization: Information Sciences Institute, Univ. of So. California Lines: 37 In article <6264@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: > >Here is a question: Which of those problems are sidestepped by >volatile variables? I would guess that at least roundoff anomalies, >as demonstrated by the code fragment > > double a, b, n, d; > > a = n / d; > func(); /* clobber fp accumulator */ > b = n / d; > if (a != b) > printf("eh?\n"); > >where a 64-bit `a' might be compared with an 80-bit accumulator, >would be avoided if `b' were declared `volatile'. But there may >be more to this. This is a mess. C is looking more and more like a throwback to an earlier era, disregarding all we've learned about program semantics and abstract data types in the last decade. Either the language can be strongly typed, or it can't. If it can, then a comparison of `a' with an 80- bit accumulator is a type violation. What can we prove about any program if we can't even make the kinds of simple comparisons in the cited passage (assuming that func() does not change the value of `a')? I WANT to be able to say float a, b; and KNOW that they are the same TYPE. A TYPE has two characteristics: a set of operations (with precise semantics), and a representation. It is insufficient to say ``use C++, or use LISP'' because many of these are written in C. Larry Miller