delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/30/01:17:03

Message-ID: <324F415E.5123@viemeister.com>
Date: Mon, 30 Sep 1996 00:41:18 -0400
From: Ian Viemeister <ian AT viemeister DOT com>
MIME-Version: 1.0
To: Guillermo Ballester Valor <gbv AT ctv DOT es>
CC: djgpp AT delorie DOT com
Subject: ldexp problems (was Re: HELP: What's wrong ?)
References: <01bbae54$12da4180$LocalHost AT 10 DOT 0 DOT 1 DOT 1 DOT inf>

This is odd.  I checked, and found exactly the same problem (fifth call 
to ldexp always causes SIGFPE).  HOWEVER, if you leave off the "-lm", 
and use the non-math library ldexp, no floating-point error occurs.
As the obivous quick-fix, Guillermo, just don't link with libm.a

***Note to whoever is currently maintaining the math libs: 
Is this a general bug, or is it possibly related to a particular setup?

Ian
ian AT viemeister DOT com
http://viemeister.com/

Guillermo Ballester Valor wrote:
> There is only a problem. I cannot find the solution. When I use 'ldexp'
> function, defined in math.h, program breaks. On the contrary Borland
> compiler works well. I don't know what's wrong. Below,  I have inserted a
> simple p.cpp which produces a runtime error. I have observed that it always
> appears in fifth call to ldexp, whatever be the arguments.

> Compiler Invoke: gxx -g -o p.exe p.cpp -lm
> 
> PROGRAM : P.CPP
> 
> /* This is a simple program test for ldexp function */
> #include <math.h>
> #include <stdio.h>
> void test(double d, int n)
> {
>         double d1=ldexp(d,n);
>         printf("\nldexp(%lf , %i ) is %lf",d,n,d1);
> }
> 
> main()
> {
>         test(1,1);
>         test(1,32);
>         test(4,16);
>         test(16,32);
>         test(32,32);
>         test(2.5,7);// and so on ... Always breaks in fifth call
> }
> 
> I would like to know if I am doing something incorrect. Please help me.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019