On Thu, Aug 26, 2010 at 12:37:03PM -0700, Niko Tyni wrote: > As seen in [rt.cpan.org #59478] and http://bugs.debian.org/593764 > overloading numeric conversion and then doing numeric comparison triggers > an unexpected IV -> NV conversion behind the scenes. > > Test 1 of the following script fails with 64-bit integers and 64-bit > doubles because precision is lost in the conversion process. > > While I can see that this may not be a bug at all, consider that > it was originally seen with the Moose test suite where an object was > overloaded to numify as its refaddr() value. Having two objects compare > as equivalent is certainly surprising behaviour here, particularly as > it only showed up on the ia64 ("Itanium") architecture where refaddr() > returns big integers instead of small ones. > > Anyway, feel free to close this ticket if it's all working as it should. > > #!perl > > package Foo; > > my $i = 1 << 53; > use overload '0+' => sub { $i++ }, > fallback => 1; > 1; > > package main; > > print "1..2\n"; > my $f1 = bless {}, 'Foo'; > my $f2 = bless {}, 'Foo'; > > print ((($f1 == $f2) ? "not " : "") . "ok 1 - equivalence first\n"); > print (((0+$f1 == 0+$f2) ? "not " : "") . "ok 2 - numification first\n"); Now fixed with this commit: commit a42d02426c51c2ef1bdefac84284a828de703cda Author: David Mitchell <davem@iabyn.com> AuthorDate: Wed Dec 15 19:38:17 2010 +0000 Commit: David Mitchell <davem@iabyn.com> CommitDate: Wed Dec 15 19:41:46 2010 +0000 don't upgrade overload IV return values to NV (if we can avoid it). Fix for RT #77456. Basically it extends the usage of the AMGf_numeric flag to the remaining overloadable numeric ops that behave differently with IV and NV. Affected files ... M lib/overload64.t M pp.c M pp_hot.c -- Modern art: "That's easy, I could have done that!" "Ah, but you didn't!"Thread Previous | Thread Next