develooper Front page | perl.perl5.porters | Postings from March 2011

RE: op/cmp.t: fix failing tests under -ffast-math

Thread Next
From:
Jan Dubois
Date:
March 28, 2011 13:17
Subject:
RE: op/cmp.t: fix failing tests under -ffast-math
Message ID:
014201cbed85$27e62aa0$77b27fe0$@activestate.com
I don't understand how "skipping tests that we know will fail" is
actually "fixing" them. Wouldn't it make more sense to just let them
fail? That way people building Perl with -ffast-math will get some
feedback that not everything may be working as they expect.

At the very least, shouldn't there be some documentation about this
silent failure anywhere? But given the size of our documentation, I
still think the failures should just be left in, with maybe a note in
README.linux that you should expect these failures if you compile with
-ffast-math, and what the consequences for your own programs might be.

Cheers,
-Jan

On Sat, 26 Mar 2011, Dave Mitchell wrote:
> 
> In perl.git, the branch blead has been updated
> 
> <http://perl5.git.perl.org/perl.git/commitdiff/e76f5e873f85fc85f1c899914749a50feed6f801?hp=976bd1ee705
> 3935efaef1e933f9101527e753e0f>
> 
> - Log -----------------------------------------------------------------
> commit e76f5e873f85fc85f1c899914749a50feed6f801
> Author: David Mitchell <davem@iabyn.com>
> Date:   Sat Mar 26 23:48:04 2011 +0000
> 
>     op/cmp.t: fix failing tests under -ffast-math
> 
>     Apparently if you compile using gcc's -ffast-math option,
>     NaNs start matching other things. So skip the NaN tests.
> -----------------------------------------------------------------------
> 
> Summary of changes:
>  t/op/cmp.t |   16 +++++++++++++++-
>  1 files changed, 15 insertions(+), 1 deletions(-)
> 
> diff --git a/t/op/cmp.t b/t/op/cmp.t
> index d811bae..0fbca5f 100644
> --- a/t/op/cmp.t
> +++ b/t/op/cmp.t
> @@ -52,10 +52,24 @@ foreach ("\x{1F4A9}", chr(163), 'N') {
>  $expect = 7 * ($#FOO+2) * ($#FOO+1) + 6 * @raw + 6 * @utf8;
>  print "1..$expect\n";
> 
> +my $bad_NaN = 0;
> +
> +{
> +    # gcc's -ffast-math option may stop NaNs working correctly
> +    use Config;
> +    my $ccflags = $Config{ccflags} // '';
> +    $bad_NaN = 1 if $ccflags =~ /-ffast-math\b/;
> +}
> +
>  sub nok ($$$$$$$$) {
>    my ($test, $left, $threeway, $right, $result, $i, $j, $boolean) = @_;
>    $result = defined $result ? "'$result'" : 'undef';
> -  print "not ok $test # ($left $threeway $right) gives: $result \$i=$i \$j=$j, $boolean disagrees\n";
> +  if ($bad_NaN && ($left eq 'NaN' || $right eq 'NaN')) {
> +    print "ok $test # skipping failed NaN test under -ffast-math\n";
> +  }
> +  else {
> +    print "not ok $test # ($left $threeway $right) gives: $result \$i=$i \$j=$j, $boolean
> disagrees\n";
> +  }
>  }
> 
>  my $ok = 0;
> 
> --
> Perl5 Master Repository


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About