choroba has asked for the wisdom of the Perl Monks concerning the following question:
While reading its delta (to decide what changes need to be done to Syntax::Construct), I noticed the following paragraph:
SIGFPE no longer deferred
Floating-point exceptions are now delivered immediately, in the same way as other "fault"-like signals such as SIGSEGV. This means one has at least a chance to catch such a signal with a $SIG{FPE} handler, e.g. so that die can report the line in perl that triggered it.
I tried to come up with code that triggers the Floating Point E{xception/rror} but I couldn't find any.
local $SIG{FPE} = sub { die "SIGNAL @_" }; my $x = 0; print 2 / $x;
I tried with sqrt -1, no difference. I asked on IRC and was given an example with Inline::C, but even that doesn't behave differently in the new Perl version:
#!/usr/bin/perl use warnings; use strict; use Inline 'C' => <<'__C__'; float killme() { volatile float f = 0.0; volatile float c = f / f; return c; } __C__ local $SIG{FPE} = sub { die "SIGNAL @_" }; print killme();
Can anyone provide an example that shows how the FPE signal is emitted and how its trapping is different in 5.36?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: FPE not deferred in 5.36
by haj (Vicar) on May 31, 2022 at 14:58 UTC | |
by choroba (Cardinal) on May 31, 2022 at 15:01 UTC | |
|
Re: FPE not deferred in 5.36
by hv (Prior) on May 31, 2022 at 15:13 UTC | |
by choroba (Cardinal) on May 31, 2022 at 15:32 UTC | |
by hv (Prior) on May 31, 2022 at 15:49 UTC | |
by choroba (Cardinal) on May 31, 2022 at 18:17 UTC |