Bugs item #3267, was opened at 2006-01-17 13:37
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=3267&group_id=426

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Sylvain Joyeux (lapinot)
Assigned to: Nobody (None)
Summary: Problem with Ruby/DL and double arguments (non-x86)

Initial Comment:
DL has a strange behaviour on my machine (Debian/PPC). This C code
[~/dl_test]% cat test.c
#include <stdio.h>
#include <math.h>

int called_by_dl(int first, double second)
{
    printf("called_by_dl(%i, %e) called\n", first, second);
    return (first == 1 && fabs(second - 0.02) < 0.00001);
}

and this Ruby code
[~/dl_test]% cat do_test.rb
require 'dl'
require 'pp'

test_lib  = DL.dlopen("./called_by_dl.so")
test_func = test_lib['called_by_dl', 'IID']
p test_func[1, 0.02]
p test_func[1, 0.02]

Gives the output:
[~/tmp/dl_test]% ruby do_test.rb
called_by_dl(1, 1.000000e+00) called
[0, [1, 0.02]]
called_by_dl(1, 2.000000e-02) called
[1, [1, 0.02]]

(i.e. first call is wrong, the second one is right)

I checked with i386 machines, where it works fine so I think it is related to the architecture. It would be nice to double-check on non-Debian non-x86 machines, but I have access to none.

Attached is the tarball with the two sources and the extconf.rb to compile the library


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=3267&group_id=426