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


Groups > comp.compilers > #62 > unrolled thread

Re: GCC/G++ compiler: Error goes away when run through debugger

Started byglen herrmannsfeldt <gah@ugcs.caltech.edu>
First post2011-03-29 18:47 +0000
Last post2011-03-29 18:47 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.compilers

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: GCC/G++ compiler: Error goes away when run through debugger glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-03-29 18:47 +0000

#62 — Re: GCC/G++ compiler: Error goes away when run through debugger

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2011-03-29 18:47 +0000
SubjectRe: GCC/G++ compiler: Error goes away when run through debugger
Message-ID<11-03-062@comp.compilers>
Torben Fgidius Mogensen <torbenm@diku.dk> wrote:

(snip)
> The moral is, of course, that I should not have used equality tests
> for FP numbers, but instead used an "within epsilon" test.  In
> general, you should not expect FP calculations to give exactly the
> same result after optimisation in C or C++, as the order of evaluation
> is not fully specified and because the compiler might optimise a
> multiplication followed by an addition to a multiply-and-add, which
> can change rounding behaviour.

In addition, many compilers do constant expression evaluation
sufficiently different from run-time evaluation that comparisons may
fail for that reason.  There are even some that use special libraries
to evaluate constant expressions to very high precision when there is
no need for such precision.

With x87 floating point, intermediate results are kept with 64
significant bits, unless the value is stored.  Sometimes even though
as written the value is stored, the optimizer will keep it in a
register.

Fortran, unlike C89 (but I believe like C99) requires parentheses to
be respected regarding evaluation order, even with mathematically
equivalent expressions.  Other than that, there are many other
optimizations that can change the value of floating point expressions,
and that are legal.

-- glen

[toc] | [standalone]


Back to top | Article view | comp.compilers


csiph-web