# New Ticket Created by "Sisyphus" # Please include the string: [perl #116569] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=116569 > >From: sisyphus1@optusnet.com.au > >In a nutshell, with 5.17.7: > >$buffer = ‘some string’; >$buf = $buffer; > >Then call an XSub that writes into $buf (by using sprintf, say). >I then find that $buffer (which should not have changed) has also been >written into, and is the same as $buf. It's still the same behaviour in 5.17.8. Is this how it's going to be in 5.18 ? Again, here's a simple demo of how things have changed between 5.16 and 5.17.7/8: #################################### use strict; use warnings; #use Inline C => Config => # BUILD_NOISY => 1; use Inline C => <<'EOC'; SV * foo(char * buffer) { char * c = "cow"; sprintf(buffer, "%s", c); return newSVpv(buffer, 0); } EOC my $buff = 'dog'; my $buf = $buff; print "\$buf: $buf\n"; print "\$buff: $buff\n"; foo($buf); print "\$buf: $buf\n"; print "\$buff: $buff\n"; #################################### On 5.17.7 and 5.17.8 that outputs $buf: dog $buff: dog $buf: cow $buff: cow On 5.16 and earlier it outputs $buf: dog $buff: dog $buf: cow $buff: dog For some (insane) reason an XS sub that changes the value of $buf, also changes the value of $buff. (Yet a perl sub that changes the value of $buf, does *not* change the value of $buff.) Cheers, RobThread Previous