This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: help understanding a gcc compilation issue


Thank you.

I would have spent some time figuring this out and might not have done it in the end.

Gabi Voiculescu

--- On Thu, 7/9/09, Ian Lance Taylor <iant@google.com> wrote:

> From: Ian Lance Taylor <iant@google.com>
> Subject: Re: help understanding a gcc compilation issue
> To: "Gabi Voiculescu" <boy3dfx2@yahoo.com>
> Cc: gcc-help@gcc.gnu.org
> Date: Thursday, July 9, 2009, 7:42 AM
> Gabi Voiculescu <boy3dfx2@yahoo.com>
> writes:
> 
> > When running, the function llrint() using and
> returning 64 bit variables fails to call rint(), and instead
> calls itself!?!.
> >
> > #include <stdio.h>
> > 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 
> >? ???return (long long) rint(x);
> > }
> >
> > When calling llrint I see the print statement repeated
> forever, without calling rint() or returning from llrint().
> 
> gcc is outsmarting itself.? When it sees "(long long)
> rint(x)", it
> converts that into "llrint(x)".? 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.
> 
> Ian
> 




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]