develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #132638] I've discovered a segfault

Thread Previous | Thread Next
From:
Zefram
Date:
December 23, 2017 07:56
Subject:
Re: [perl #132638] I've discovered a segfault
Message ID:
20171223075600.GD19698@fysh.org
Danijel Tasov wrote:
>use overload
>'eq' => \&equals_to,
...
>sub equals_to{ $_[0] eq $_[1] }

Here's your problem you've defined the "eq" overload to apply "eq" to
its operands, which invokes the "eq" overload in an infinite recursion.
The segv is just C stack overflow.  You probably want to write the "eq"
overload as

    sub equals_to{ "$_[0]" eq $_[1] }

or just remove that overload and enable overload fallback, so that Perl
will synthesise that "eq" overload for you.

There is no Perl bug here.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About