From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17745 invoked by alias); 9 Jul 2009 11:05:04 -0000 Received: (qmail 17708 invoked by uid 22791); 9 Jul 2009 11:05:02 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_46,J_CHICKENPOX_66,RCVD_IN_SORBS_WEB X-Spam-Check-By: sourceware.org Received: from web37001.mail.mud.yahoo.com (HELO web37001.mail.mud.yahoo.com) (209.191.85.86) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Thu, 09 Jul 2009 11:04:55 +0000 Received: (qmail 13843 invoked by uid 60001); 9 Jul 2009 11:04:53 -0000 Message-ID: <367172.13741.qm@web37001.mail.mud.yahoo.com> Received: from [141.85.254.64] by web37001.mail.mud.yahoo.com via HTTP; Thu, 09 Jul 2009 04:04:52 PDT Date: Thu, 09 Jul 2009 11:05:00 -0000 From: Gabi Voiculescu Subject: Re: help understanding a gcc compilation issue To: gcc-help@gcc.gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00141.txt.bz2 Thank you. I would have spent some time figuring this out and might not have done it i= n the end. Gabi Voiculescu --- On Thu, 7/9/09, Ian Lance Taylor wrote: > From: Ian Lance Taylor > Subject: Re: help understanding a gcc compilation issue > To: "Gabi Voiculescu" > Cc: gcc-help@gcc.gnu.org > Date: Thursday, July 9, 2009, 7:42 AM > Gabi Voiculescu > writes: >=20 > > When running, the function llrint() using and > returning 64 bit variables fails to call rint(), and instead > calls itself!?!. > > > > #include > > extern double rint(double x); > > > > long long llrint(double x); > > long long llrint(double x) > > { > > printf("%s,%d llrint entry\n", __func__, __LINE__); > //-gabi 07/08/2009=20 > >=A0 =A0=A0=A0return (long long) rint(x); > > } > > > > When calling llrint I see the print statement repeated > forever, without calling rint() or returning from llrint(). >=20 > gcc is outsmarting itself.=A0 When it sees "(long long) > rint(x)", it > converts that into "llrint(x)".=A0 This is normally a > safe conversion, but > of course it is unsafe when you are trying to implement > llrint itself. > You can avoid this problem by using the -fno-builtin-rint > option. >=20 > Ian >=20