This is the mail archive of the cygwin mailing list for the Cygwin 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: FPE_FLTSUB where FLT_FLTINV is expected


On Jun 25 20:51, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote:
> Hello,
> 
> The following code produces FPE_FLTSUB(22) for the signal code whereas all platforms (Linux, Mac, FreeBSD) where I tested it, consistently yield FPE_FLTINV
> (which on CYGWIN has a value of 21):
> 
> #define _GNU_SOURCE
> #include <fenv.h>
> #include <signal.h>
> #include <stdio.h>
> #include <string.h>
> #include <unistd.h>
> 
> void sigfpe(int signo, siginfo_t* si, void* ucontext)
> {
>     printf("code = %d\n", si->si_code);
>     _exit(255);
> }
> 
> int main()
> {
>     double a = 0, b = 0;
>     struct sigaction sa;
>     memset(&sa, 0, sizeof(sa));
>     sa.sa_sigaction = sigfpe;
>     sa.sa_flags = SA_SIGINFO;
>     sigaction(SIGFPE, &sa, 0);
>     feenableexcept(FE_ALL_EXCEPT);
>     printf("%lf", a / b);
>     return 0;
> }
> 
> I suppose that this block of code in exceptions.cc is not particularly correct, and only the last case (STACK_CHECK) actually pertains to the FLTSUB situation,
> while all previous labels should be redirected to FPE_FLTINV (which, BTW, seems not being used at all in CYGWIN):
> 
>     case STATUS_FLOAT_DENORMAL_OPERAND:
>     case STATUS_FLOAT_DIVIDE_BY_ZERO:
>     case STATUS_FLOAT_INVALID_OPERATION:
>     case STATUS_FLOAT_STACK_CHECK:
>       si.si_signo = SIGFPE;
>       si.si_code = FPE_FLTSUB;
>       break;
> 
> Thanks for looking into this!

Thanks for the testcase!  I pushed a patch.  Expect new devloper
snapshots on https://cygwin.com/snapshots later today.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


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