I've found the bug on Linux Sparc; This is either a bug in Parrot, or a bug in
Perl, and I can't tell which.

On this machine, NVs are doubles; their pack_type is 'd', which is as it should
be. So, a number (2.0) is inserted into the bytecode stream with pack('d', 2.0)

However, when I try dereferencing this as an NV, I get a bus error.
Here's the debug:

Program received signal SIGBUS, Bus error.
0x15230 in Parrot_op_set_n_nc (cur_opcode=0x7001c044, interpreter=0x30028) at 
basic_opcodes.c:276
276       NUM_REG(cur_opcode[1]) = *(NV *)&cur_opcode[2];
(gdb) x/dg &cur_opcode[2]
0x7001c04c:     4611686018427387904
(gdb) x/fg &cur_opcode[2]
0x7001c04c:     2

Now, notice that when I use the *float* pattern to dereference it, I get the
right answer. This leads me to believe that pack("d") in Perl 5.6.1 on Sparc
Linux is not packing "double-precision float in the native format" as it claims,
but is actually packing a single-precision float.

I know there's been some discussion about pack on p5p recently, but I haven't
been able to get my head around it. Jarkko, does this ring any bells?

-- 
How do I type "for i in *.dvi do xdvi i done" in a GUI?
(Discussion in comp.os.linux.misc on the intuitiveness of interfaces.)

Reply via email to