Closed GoogleCodeExporter closed 9 years ago
So either compile Sub::Name (there's only the XS, so it comes with no cost), or
use -O2 for this usecase.
Changing a static string is not allowed with -O3.
0x00007ffff632ffc2 in XS_Sub__Name_subname (cv=0xab3358) at Name.xs:67
67 *end = 0;
(gdb) p end
$1 = 0x734884 <pv5+6> "bar"
Original comment by reini.urban
on 6 Jun 2014 at 3:53
perlcc -O3 -e'use Sub::Name; Sub::Name::subname("main::bar", sub { 42 } );
print "ok\n"'
also does not work, so we have to patch Sub::Name.
Original comment by reini.urban
on 6 Jun 2014 at 3:56
Other possible workarounds are:
use a name without :: and '
perlcc -O3 -e'use Sub::Name; subname("bar", sub { 42 } ); print "ok\n"'
or set the glob and be able to actually call it:
perlcc -O3 -e'$cv=sub{42}; *bar=*sub; print $bar->()'
perlcc -O3 -e'$cv=sub{42}; $bar=$sub; print $bar->()'
Original comment by reini.urban
on 6 Jun 2014 at 4:08
Or just use a variable instead of a constant string:
perlcc -O3 -e'use Sub::Name; $x="main::bar"; subname($x, sub { 42 } ); print
"ok\n"'
ok
Original comment by reini.urban
on 6 Jun 2014 at 4:10
Fixed in the core testsuite with commit dd9169183e1c769d1de57c929b9183e23ecb9088
Author: Reini Urban <rurban@cpanel.net>
Date: Wed Jul 2 12:20:05 2014 -0500
t/CORE/mro/next_edgecases.t: fix wrong usage of constant string with Sub::Name
Sub::Name changes the string argument, which will fail with constant strings
in perlcc -O3 and embedders. Sub::Name really needs to return a copy then.
See https://code.google.com/p/perl-compiler/issues/detail?id=345
Haven't filed a Sub::Name ticket yet
Original comment by reini.urban
on 2 Jul 2014 at 5:21
See https://rt.cpan.org/Ticket/Display.html?id=96893 for a pull request with
Sub-Name-0.06
Original comment by reini.urban
on 2 Jul 2014 at 8:56
Original issue reported on code.google.com by
nicolas....@gmail.com
on 5 Jun 2014 at 9:41