Closed p5pRT closed 21 years ago
When a scalar that has a numerical value is assigned a constructed string that evaluates to a numerical value\, the previous numerical value is sometimes not invalidated.
e:\> perl -e "my $x = 10; $x = '2' . $x; print $x + 0" 10
Any simple calculation that produces a wrong value quietly is potentially a serious problem and should be addressed. I called its severity 'medium' because Perl has survived this far without exploding any nuclear reactors. :-)
When a scalar that has a numerical value is assigned a constructed string that evaluates to a numerical value\, the previous numerical value is sometimes not invalidated.
Okay\, this sucks.
e:\> perl -e "my $x = 10; $x = '2' . $x; print $x + 0" 10
Here's what's happening: When Perl does a concatentation or substr\, it uses sv_insert to put string into another. However\, sv_insert fails to invalidate the IVness of the SV. It should do this once it's converted the SV into a PV\, since the SV is about to change. Here's the OLF:
I called its severity 'medium' because Perl has survived this far without exploding any nuclear reactors. :-)
It's certainly a core problem though...
Simon __END__
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review\, retransmission\, dissemination or other use of\, or taking of any action in reliance upon\, this information by persons or entities other than the intended recipient is prohibited. If you received this in error\, please contact the sender and delete the material from any computer.
I stumbled:
Boy, oh, boy. Better make that SvPVOK_only(bigstr); since floating-point numbers exist.
Simon __END__
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review\, retransmission\, dissemination or other use of\, or taking of any action in reliance upon\, this information by persons or entities other than the intended recipient is prohibited. If you received this in error\, please contact the sender and delete the material from any computer.
Larry Rosler \lr@​hpllr1\.hpl\.hp\.com wrote
e:\> perl -e "my $x = 10; $x = '2' . $x; print $x + 0" 10
Any simple calculation that produces a wrong value quietly is potentially a serious problem and should be addressed. I called its severity 'medium' because Perl has survived this far without exploding any nuclear reactors. :-)
The real reason no nuclear reactors have exploded is that this bug doesn't happen in 5.005_03\, and 5.6.0 hasn't been around very long.
So it's a good thing Simon has provided a patch.
Mike Guy
M.J.T. Guy (lists.p5p):
The real reason no nuclear reactors have exploded is that this bug doesn't happen in 5.005_03
It doesn't happen in globals either; only lexicals. I don't know why that is.
On Wed\, Apr 26\, 2000 at 03:42:20PM +0000\, simon@brecon.co.uk wrote:
M.J.T. Guy (lists.p5p):
The real reason no nuclear reactors have exploded is that this bug doesn't happen in 5.005_03
It doesn't happen in globals either; only lexicals. I don't know why that is.
Gosh\, does that mean that perl scripts written for nuclear reactors don't use lexical variables?
fixed in 5.6.1
@iabyn - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#3161 (status was 'resolved')
Searchable as RT3161$