From owner-freebsd-questions@FreeBSD.ORG Sat Sep 11 10:10:45 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C1EB106564A for ; Sat, 11 Sep 2010 10:10:45 +0000 (UTC) (envelope-from brampton@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id DF0168FC0C for ; Sat, 11 Sep 2010 10:10:44 +0000 (UTC) Received: by qyk31 with SMTP id 31so248862qyk.13 for ; Sat, 11 Sep 2010 03:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=K386+iibZDq8LZTov2KsA4D2Pyda5eMwkuwMaVB86JA=; b=HrZS7ajLYrD0hLZDC/CLKwNgyihkAI3vfb2dCmAIe/xM2FxEF6j7klQeDhu4kPNdOa hnJmMWcxLjtY6iT3WprQ5L3CQ2aFyNIpFHKcVG25AVUA45lP84ZP90LL2xRAtjNz28b+ HLCCHvg+tdRMEV8utnwxlCFN/Cc2o+s4agJxs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=DK2FaHEimmneuRTIOOfk//cs1Uo8PktvNR0OWS/vy9POAbPYZvfh4wC20VF2UMq+sO qPRQcZqWmf7pP0tRfwCnWmnV1wfA3shXKlyETnPcqdTYSJ5AOUWllS+Dh3tvfBkgNY9H guUXPbgpaIPJbDVIMWDv1ZgidECOo0VrfIngA= MIME-Version: 1.0 Received: by 10.224.78.233 with SMTP id m41mr1189331qak.27.1284198212574; Sat, 11 Sep 2010 02:43:32 -0700 (PDT) Sender: brampton@gmail.com Received: by 10.229.110.7 with HTTP; Sat, 11 Sep 2010 02:43:32 -0700 (PDT) In-Reply-To: <4C8B4BC0.1000900@mail.zedat.fu-berlin.de> References: <4C8B4BC0.1000900@mail.zedat.fu-berlin.de> Date: Sat, 11 Sep 2010 10:43:32 +0100 X-Google-Sender-Auth: n6npPm4_u8OIjJVg81Kwgvrqxgk Message-ID: From: Andrew Brampton To: "O. Hartmann" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org Subject: Re: Compiling software with different compiler than cc or clang results in unusable output X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Sep 2010 10:10:45 -0000 On 11 September 2010 10:28, O. Hartmann wrote: > > Dear Sirs, > > you see me a kind of desperate. I wrote my own a small piece of =C2=A0sof= tware in > C, calculating the orbit and position of astronomical objects, astroids, = in > a heliocentric coordinate system from Keplerian orbital elements. So far. > The software calculates the set of points of an ellipse based upon > ephemeridal datas taken from the Minor Planet Cataloge. Again, so far, > everything all right. The set of points of an orbit is all right and > correct. But when it comes to positions at a specific time, then I loose > hair! > > Compiling this piece of software with FreeBSD's gcc (V4.2) and clang (cla= ng > devel) on my private and lab's FreeBSD boxes (both most recent FreeBSD > 8.1/amd64), this program does well, the calculated orbital positions are > very close to professional applications or observational checks. But when > compiling the sources with gcc44 or gcc45 (same source, same CFLAG settin= g, > mostly no CFLAGS set), then there is a great discrepancy. Sometimes when > plotting positions, the results plotted seconds before differs from the m= ost > recent. The ellipses are allways correct, but the position of a single po= int > at a specific time isn't correct. > > I use the GNU autotools to build the package. > > I suspekt miscompilations in memory alloction or in some time- or > mathematical functions like sin, cos. > > before I digg deeper I'd like to ask the community for some hints how to > hunt down such a problem. > > regards, > Oliver Sounds a cool project. I suspect you are miss-using a feature of C or are using uninitialised memory, and with gcc44/45's more aggressive optimisations it is getting it wrong. I have three suggestions 1) Use valgrind to check if it finds anything wrong when running your program. Check both the good and the bad builds. 2) If your program is made up of multiple C files, then try compiling all of the C files with gcc42, but just one at a time with gcc44. This way will help you track down exactly which C file has "the bug". 3) Finally do some printf debugging to find the first line of code that is generating the wrong value. I hope these suggestions help. Andrew