FPE_FLTSUB where FLT_FLTINV is expected
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Jun 26 14:18:00 GMT 2018
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20180626/3bf7c450/attachment.sig>
More information about the Cygwin
mailing list