Bill Allombert on Tue, 27 Apr 2004 10:41:59 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: link error log2 exp2 gcc 3.4.0 and resolution


On Sun, Apr 25, 2004 at 04:36:21PM -0700, Carl Hansen wrote:
> #include <math.h>
> main(){ double x=log2(1.0); }
> 
> compiles cleanly,
> 
> however trying:
> 
> #include <math.h>
> main(){ double x=log2(0.666); }
> 
> get        Undefined  symbol   log2
> 
> 
> Having pondered, conclude the compiler compile-time-optimises
> log2(1.0)  to 0 , so log2 is never  called at runtime, as
> can be verified by looking at has_log2.s , so the Configure script
> will conclude has it HAS log2, whereas  in  the
> other case log2(0.666), Configure script will realise
> we  in fact DON'T have log2.

We should probably test a non-constant value:

double log4(double x) { return log2(x)/2;}

A compiler could decide to optimize log2(0.666) to -0.586405917590824
or whatever is the valid ieee754 result.

Cheers,
Bill.