Bug returning Fixnums >= 2**30 in the C API
-------------------------------------------

                 Key: JRUBY-5029
                 URL: http://jira.codehaus.org/browse/JRUBY-5029
             Project: JRuby
          Issue Type: Bug
          Components: Extensions
         Environment: $ ~/jruby/bin/jruby -v
jruby 1.6.0.dev (ruby 1.8.7 patchlevel 249) (2010-08-20 9a285a3) (OpenJDK 
Client VM 1.6.0_18) [i386-java]
$ uname -a
Linux ubuntu 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 07:54:58 UTC 2010 i686 
GNU/Linux
            Reporter: Jeremy Evans


There is a bug in the C API related to returning Fixnums greater than or equal 
to 2**30 in the C API.  2**31 ends up being subtracted from them, as shown by 
this code:

Example Extension:

{noformat}
#include <ruby.h>

static VALUE jrt(VALUE self) {
  printf("%li\n",NUM2LONG(rb_funcall(self, rb_intern("to_i"), 0)));
  rb_funcall(self, rb_intern("p"), 1, rb_funcall(self, rb_intern("to_i"), 0));
  return LONG2NUM(NUM2LONG(rb_funcall(self, rb_intern("to_i"), 0)));
}

void Init_jrt(void) {
  rb_define_method(rb_cTime, "jrt", jrt, 0);
}
{noformat}

Output:

{noformat}
$ ~/jruby/bin/jruby -r jrt -e "p Time.now.jrt; p :-; p Time.at(2**30).jrt; p 
:-; p Time.at(2**30 - 1).jrt"
calling init (7477c4)
-865143417
-865143417
-865143417
:-
-1073741824
-1073741824
-1073741824
:-
1073741823
1073741823
1073741823
{noformat}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to