delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/06/28/13:53:08

X-Spam-Check-By: sourceware.org
Message-ID: <4683F56D.53B8E259@dessent.net>
Date: Thu, 28 Jun 2007 10:52:45 -0700
From: Brian Dessent <brian AT dessent DOT net>
X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: possible compiler optimization error
References: <C6EEDB0EB45A56439F73B1D23E39694A35C7EC AT USORL02P702 DOT ww007 DOT siemens DOT net>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

"Frederich, Eric P21322" wrote:

> If a program compiled with -O0 has different output than the same
> program compiled with -O1 or -O2, is that defiantly a compile error?
> I do realize that it could be a combination of compiler optimizations
> along with the platform's representation of floating point numbers, but
> isn't that something the compiler should be aware of be careful about?

On the contrary, when a program fails with optimization and not without
it is almost always a bug in the code that relies on undefined behavior
or incorrect floating point assumptions, not anything wrong with the
compiler.

Try with -ffloat-store.  Or if you have a sse2 capable machine, set the
appropriate -march= and use -mfpmath=sse.  Both of these attempt to
bypass problems caused by the excess precision of 80 bit double on
i387.  If they fix the problem, it's a bug in your code, not anything to
do with the compiler.  It looks like you limit the precision in the
output in your printfs to 15 places, but then you don't understand why
comparison operators don't compare the same... that is very telling, in
that you don't understand the excess precision problem.  Of course they
look the same if you limit the precision!  But that's not how the
comparison operators work, as they operate on the raw 80 bit values.

If you want a definitive answer then you need to provide a standalone
testcase that compiles.  Sample code taken out of context that can't be
compiled is significantly less useful.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019