Skip to content

Useless use of const in void context in lib/unicore/mktables #23520

@richardleach

Description

@richardleach

Description
Poking around for #23448 showed a possible bug in line 16093 of lib/unicore/mktables:

my $sub_filename = join('/', $directory_ref->[1, -1], $file);

which will behave as:

my $sub_filename = join('/', $directory_ref->[-1], $file);

because the 1 is in scalar context and gets optimised away:

1    list LISTOP(0x561f9b37ace8) ===> 2 [aelem 0x561f9b37ac70]
     PARENT ===> 2 [aelem 0x561f9b37ac70]
     FLAGS = (SCALAR,KIDS,SLABBED)
     |   
3    +--pushmark OP(0x561f9b37ad60) ===> 4 [const 0x561f9b37ad28]
     |   FLAGS = (VOID,SLABBED,MORESIB)
     |   
5    +--null (ex-const) OP(0x561f9b37ad98) ===> 4 [const 0x561f9b37ad28]
     |   FLAGS = (VOID,SLABBED,MORESIB)
     |   
4    +--const SVOP(0x561f9b37ad28) ===> 1 [list 0x561f9b37ace8]
         FLAGS = (SCALAR,SLABBED,FOLDED)
         SV = IV(-1)

(There's no warning emitted because of the special treatment of constants 0 and 1.)

Expected behavior
I'm not familiar with the operation of this script, so don't know if this line is behaving
as intended (and could have the 1, removed) or is subtly buggy.

Perl configuration
blead

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions