Skip Menu |

This queue is for tickets about the Math-Complex CPAN distribution.

Report information
The Basics
Id: 56149
Status: resolved
Priority: 0/
Queue: Math-Complex

People
Owner: Nobody in particular
Requestors: CHORNY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.56
Fixed in: (no value)



Subject: Math::Complex has no copy constructor
Math::Complex has no copy constructor and thus problems appear when copy or original is modified by "mutator" operation. Found in this perlbug report: http://rt.perl.org/rt3/Ticket/Display.html?id=61142 Attached file is seriously simplified version of example in rt.perl.org and can be used as a test. -- Alexandr Ciornii, http://chorny.net
Subject: copybug.pl
#!/usr/bin/perl use strict; use warnings; use Math::Complex; my $q = Math::Complex->make(5, 0); $q->display_format('cartesian'); my $qn = $q; print "q=qn=$qn\n"; $q += 1; #$q = $q + 1; print "q=$q\n"; print "qn=$qn\n";
On Wed Mar 31 06:46:55 2010, CHORNY wrote: I created a copy constructor, but it does not get called. sub _copy { my $self = shift; my $clone = {%$self}; if ($self->{'cartesian'}) { $clone->{'cartesian'}=[@{$self->{'cartesian'}}]; } if ($self->{'polar'}) { $clone->{'polar'}=[@{$self->{'polar'}}]; } bless $clone,__PACKAGE__; return $clone; } -- Alexandr Ciornii, http://chorny.net
Fixed in Math-Complex-1.57, just uploaded to CPAN.