Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #2846

Re: What is the meaning of an expression?

From gah4 <gah4@u.washington.edu>
Newsgroups comp.compilers
Subject Re: What is the meaning of an expression?
Date 2022-01-19 14:03 -0800
Organization Compilers Central
Message-ID <22-01-073@comp.compilers> (permalink)
References (3 earlier) <22-01-066@comp.compilers> <22-01-067@comp.compilers> <22-01-068@comp.compilers> <22-01-069@comp.compilers> <22-01-070@comp.compilers>

Show all headers | View raw


(snip, I wrote)
> > > So, back to anthropomorphic computers and logical
> > > inconsistencies. How good are compilers, especially ones
> > > that evaluate constant expressions at compile time, at
> > > dealing with logic failure?

(snip)
> An analogy: There exist two kinds of compression algorithms: lossy and
> lossless. Similarly, there exist two kinds of optimization algorithms. If it
> is a lossless optimization algorithm, then any kind of difference between
> compile-time evaluation and run-time evaluation is a software bug in the
> optimizer. If it is a lossy optimization algorithm, then it should be
> sufficiently clearly specified what kind of information is permitted to be
> lost during the optimization process.

I find the other way around more interesting.

There is a popular Fortran compiler that uses an high precision arithmetic
package to evaluate constant expressions.  As I understand it, it will
accurately calculate sin(1e100).   At run time, though, you only have
normal machine precision.

In most science/engineering problems, data has an uncertainty, and
floating point well represents data with a relative uncertainty. There
is no reasonable answer to sin(x) when x has an uncertainty
of more than 2*pi.  (There is an extremely small branch of mathematics
where problems like this might occur. But never in physics or engineering.)

But in any case, calculating constant expressions more accurately
(or less accurately) means that they won't be equal to the same thing
calculated at run time. (Now, people are supposed to know not to
compare floating point values for equality, but it is still surprising.)

Early Fortran didn't have constant expressions, so any such evaluation
was optional optimization.  More recent versions do, though, so there
are some things that the compiler is required to evaluate at compile time.

I believe that there are cases equivalent to the mentioned C++ cases.

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

What is the meaning of an expression? Roger L Costello <costello@mitre.org> - 2022-01-14 12:15 +0000
  Re: What is the meaning of an expression? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2022-01-14 18:20 +0000
  Re: What is the meaning of an expression? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-01-15 00:28 +0100
  Re: What is the meaning of an expression? gah4 <gah4@u.washington.edu> - 2022-01-14 17:58 -0800
  Re: What is the meaning of an expression? George Neuner <gneuner2@comcast.net> - 2022-01-15 02:05 -0500
  Re: What is the meaning of an expression? "matt.ti...@gmail.com" <matt.timmermans@gmail.com> - 2022-01-15 06:21 -0800
    Re: What is the meaning of an expression? Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2022-02-03 12:50 +0000
  Re: What is the meaning of an expression? Jan Ziak <0xe2.0x9a.0x9b@gmail.com> - 2022-01-16 07:44 -0800
    Re: What is the meaning of an expression? Jan Ziak <0xe2.0x9a.0x9b@gmail.com> - 2022-01-17 15:45 -0800
      Re: What is the meaning of an expression? Jan Ziak <0xe2.0x9a.0x9b@gmail.com> - 2022-01-18 10:03 -0800
        Re: What is the meaning of an expression? gah4 <gah4@u.washington.edu> - 2022-01-18 15:18 -0800
          Re: What is the meaning of an expression? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-01-19 11:54 +0100
            Re: What is the meaning of an expression? Jan Ziak <0xe2.0x9a.0x9b@gmail.com> - 2022-01-19 09:17 -0800
              Re: What is the meaning of an expression? gah4 <gah4@u.washington.edu> - 2022-01-19 14:03 -0800
              Re: What is the meaning of an expression? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-01-20 13:02 +0100
                Re: What is the meaning of an expression? dave_thompson_2@comcast.net - 2022-01-30 22:51 -0500
            Re: What is the meaning of an expression? Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-01-19 20:13 +0200
              Re: What is the meaning of an expression? Thomas Koenig <tkoenig@netcologne.de> - 2022-01-22 20:46 +0000
  Re: What is the meaning of an expression? Thomas Koenig <tkoenig@netcologne.de> - 2022-01-19 20:51 +0000

csiph-web