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@xxxxxxxxxx> wrote: > From: Ian Lance Taylor <iant@xxxxxxxxxx> > Subject: Re: help understanding a gcc compilation issue > To: "Gabi Voiculescu" <boy3dfx2@xxxxxxxxx> > Cc: gcc-help@xxxxxxxxxxx > Date: Thursday, July 9, 2009, 7:42 AM > Gabi Voiculescu <boy3dfx2@xxxxxxxxx> > 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 >