Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.95k stars 554 forks source link

op/pack.t: handle sizeof (IV) > sizeof (void *) #22619

Closed mauke closed 3 weeks ago

mauke commented 1 month ago

This test tries to get the integer representation of a pointer via unpack 'j', pack 'P'. But an IV is not necessarily the same size as a pointer. In particular, on 32-bit platforms with -Duse64bitint we have sizeof (IV) == 8 and sizeof (void *) == 4, which makes unpack 'j' fail (the input string is too short) and return undef.

Work around the issue by checking for the most common pointer sizes (4 and 8 bytes) and selecting an appropriate integer unpack format. In all other cases (exotic platforms?), just skip the test.

Fixes #22618 ­– hopefully.


Leont commented 1 month ago

You can also just use $Config{ptrsize} to get the pointer size

sisyphus commented 1 month ago

Proposed PR works fine for me on 32-bit Windows (MSWin32-x86-multi-thread-64int).