This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: strange behaviour powl
- From: Brian Dessent <brian at dessent dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 31 Jan 2006 15:18:38 -0800
- Subject: Re: strange behaviour powl
- References: <43DFC01D.40008@UvT.nl>
David Vonka wrote:
> Note that the only difference is "1" instead of "K" on line 3.
> I compile by following command:
>
> gcc blan.c -lm
>
> In case A the answer of gcc is
> /cygdrive/c/Temp/ccEHzDhs.o:blan.c:(.text+0x30): undefined reference to
> `_powl'
> collect2: ld gaf exit-status 1 terug
There is no need to ever use -lm under Cygwin because all math functions
are in the main cygwin1.dll. Specifying -lm is a no-op.
> In case B the program compiles without any problem and returns correct
> answer when run. Both programs compile when substituting "pow" for
> "powl". The switch "-lm" makes no difference(!), the result is exactly
> the same without it.
Cygwin does not provide an implementation of powl(). In case B the
compiler optimized away the call to the function because it recognised
that raising a number to the power of 1 does nothing.
Brian