On Tue, Jan 24, 2012 at 12:26 PM, Father Chrysostomos via RT < perlbug-followup@perl.org> wrote: > On Tue Jan 24 09:14:08 2012, rurban wrote: > > The reason of the failure is Config::Config{ptrsize} == > > $Config::Config{intsize}. > > On the failing platform it is 4 vs 8. > > > > So use unpack "I" instead. > > Eric Brine’s patch has already been applied as 6fa2c250307, but yours > looks more robust to me, er, I *think*. > > Is it guaranteed that unpack "J" will return undef in those cases where > it fails? > Assuming we take it for granted that these unpack return undef when the string is too short (even though that's not documented). If sizeof(void*) == sizeof(UV): No problem If sizeof(void*) < sizeof(UV) && sizeof(void*) == sizeof(int): Ok If sizeof(void*) < sizeof(UV) && sizeof(void*) > sizeof(int): Won't work, but not currently possible. If sizeof(void*) < sizeof(UV) && sizeof(void*) < sizeof(int): Won't work, but not currently possible. If sizeof(void*) > sizeof(UV): Impossible UV are guaranteed to be large enough to hold a pointer, If you want more robust, I'd recommend: my $ptrlen = length(pack("P", "abc")); my $ptrfmt = $ptrlen == length(pack("J", 0)) ? "J" : $ptrlen == length(pack("I", 0)) ? "I" : die; - EricThread Previous | Thread Next