lkml.org 
[lkml]   [2002]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: floating point exception
From
Date
On Tue, 2002-01-15 at 19:31, Richard B. Johnson wrote:
> On 15 Jan 2002, Christian Thalinger wrote:
>
> > On Tue, 2002-01-15 at 15:34, Zwane Mwaikambo wrote:
> > > On 14 Jan 2002, Christian Thalinger wrote:
> [SNIPPED...]
>
> >
> > Tried this:
> >
> > #define _GNU_SOURCE 1
> > #include <fenv.h>
> >
> > main() {
> > double zero=0.0;
> > double one=1.0;
> >
> > feenableexcept(FE_ALL_EXCEPT);
> >
> > one /=zero;
> > }
> >
> Well, that won't even link. The source I showed previously
> compiles and link fine. It also shows a FPU exception when
> one divides by zero:
>
> Script started on Tue Jan 15 13:27:05 2002
> # gcc -o zzz zzz.c -lm
> /tmp/ccjhyGHj.o: In function `main':
> /tmp/ccjhyGHj.o(.text+0x25): undefined reference to `feenableexcept'
> collect2: ld returned 1 exit status

This depends on the libc version. Seems you have 2.1. For me it's 2.2.

[root@sector17:/root/src]# cat fpu-exception.c
#define _GNU_SOURCE 1
#include <fenv.h>

main() {
double zero=0.0;
double one=1.0;

feenableexcept(FE_ALL_EXCEPT);

one /=zero;
}
[root@sector17:/root/src]# gcc -Wall -lm -o fpu-exception
fpu-exception.c
fpu-exception.c:4: warning: return type defaults to `int'
fpu-exception.c: In function `main':
fpu-exception.c:11: warning: control reaches end of non-void function
[root@sector17:/root/src]# ./fpu-exception
Floating point exception
[root@sector17:/root/src]#


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:23    [W:0.058 / U:7.288 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site