in reply to Re^3: [OT] C++ mystery.
in thread [OT] C++ mystery.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: [OT] C++ mystery.
by BrowserUk (Patriarch) on Jun 20, 2015 at 01:15 UTC | |
According to this and (for me) this, that should either not happen; or at least be controllable. But then, that may not have been the case for which compiler the code was originally (or subsequently) targeted at; so it's a good thought. Thank you. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
| [reply] |
by bitingduck (Deacon) on Jun 20, 2015 at 03:39 UTC | |
I took a look through some of the source code you linked, and the type cast seems to be applied in particular when there's a subtraction that's obviously close to zero. I don't have enough C++ experience to know how the compilers are expected to behave on such things (even more so older versions), but I walked through a bunch of the arithmetic and there's a lot of adding and subtracting things that should either add up to zero or add up neatly to just one of the terms that was in a previous step, so I'm actually a little surprised that there aren't more oddball things in there (or at least a note about setting a compiler directive not to simplify) to keep the epsilons from getting optimized away. There are enough things that just cancel away in odd ways that I was partly looking to verify you hadn't made any typos! EDIT: in your first link it actually points out that the Intel C++ compiler does allow associativity transformations by default, so it may be a bit of legacy code to prevent that. | [reply] |
by BrowserUk (Patriarch) on Jun 20, 2015 at 13:45 UTC | |
in your first link it actually points out that the Intel C++ compiler does allow associativity transformations by default, so it may be a bit of legacy code to prevent that. It seems that both gcc and icc also have options specifically aimed at the problem: Gnu compilers default to observing parentheses in accordance with language standards. Traditional C K&R behavior of permitting elision of parentheses according to algebraic rules is included in gcc –ffast-math and icc –fp-model fast. But when these things came to be isn't clear. That said; the Kahan summation algorithm goes back to 1989; and compiler writers have been aware of it for a long time. Of course; that says nothing about the various programmers who've had their hands on this code since. All of which leaves me with a possibility; but none the wiser :( With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
| [reply] [d/l] |