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: strange behaviour powl


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


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