X-Spam-Check-By: sourceware.org From: "Dave Korn" To: References: Subject: RE: possible compiler optimization error Date: Thu, 28 Jun 2007 18:39:19 +0100 Message-ID: <006a01c7b9ab$418ca130$2e08a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 28 June 2007 18:19, Frederich, Eric P21322 wrote: > On Windows I have found that a program I wrote fails when compiled with > -O1 and -O2 but runs fine with -O0. > The program behaves correctly on Linux and Solaris with or without > optimizations. Your code has a bug, most likely an uninitialised or otherwise stray pointer, but could be anything that causes undefined behaviour. It works on Linux/Solaris by good fortune, because whatever memory addresses you're stomping all over just happen to be free and safe to stomp on on those platforms, whereas windows systems have different process space layout > If a program compiled with -O0 has different output than the same > program compiled with -O1 or -O2, is that defiantly a compile error? No. Very occasionally it is a genuine compiler bug in one of the optimisation passes, but the *vast* majority of such 'bugs' are actually in the source code fed to the compiler. (Like many utilities, the compiler cannot always detect when it is fed invalid input, and may sometimes silently produce invalid output as a result.) Now, there /could/ be a compiler bug, but unless you can present us with a testcase that we can compile ourselves and test out, it's not going to be easy to help you. Fragmentary code snippets aren't useful. For advice on how to write a really good compiler bug report, see the guidelines at http://gcc.gnu.org/bugs.html cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/