https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103088

--- Comment #20 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Aldy Hernandez from comment #19)
> Ughh, I was nerd sniped.  Couldn't let it go ;-).
> 
> The problem is this construct in Perl_do_ncmp:
> 
>       if (lnv < rnv)
>         return -1;
>       if (lnv > rnv)
>         return 1;
>       if (lnv == rnv)
>         return 0;
>       return 2;
> 
> These are all doubles.  The code is depending on a pair of values that are
> neither <, >, nor ==, being a NAN.

And...you can work around the problem by declaring the doubles volatile ;-):

      volatile NV const rnv = SvNV_nomg(right);
      volatile NV const lnv = SvNV_nomg(left);
...
...
      if (lnv < rnv)
        return -1;
      if (lnv > rnv)
        return 1;
      if (lnv == rnv)
        return 0;
      return 2;

Reply via email to