Skip to content

Commit

Permalink
Fix optional/gc_specs.rb and use LL2NUM instead of LONG2NU
Browse files Browse the repository at this point in the history
INT64_MAX might be long long int and there might be overflow with LONG2NU, e.g. in windows job:
```
gc_spec.c: In function 'Init_gc_spec':
gc_spec.c:108:58: warning: overflow in conversion from 'long long int' to 'long int' changes value from '9223372036854775807' to '-1' [-Woverflow]
  108 |   registered_before_rb_global_variable_bignum = LONG2NUM(INT64_MAX);
      |                                                          ^~~~~~~~~
gc_spec.c:113:57: warning: overflow in conversion from 'long long int' to 'long int' changes value from '9223372036854775807' to '-1' [-Woverflow]
  113 |   registered_after_rb_global_variable_bignum = LONG2NUM(INT64_MAX);
      |                                                         ^~~~~~~~~
```
  • Loading branch information
andrykonchin committed Mar 29, 2024
1 parent 118bfc5 commit 23ab41b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions optional/capi/ext/gc_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ void Init_gc_spec(void) {
registered_before_rb_gc_register_address = rb_str_new_cstr("registered before rb_gc_register_address()");

registered_before_rb_global_variable_string = rb_str_new_cstr("registered before rb_global_variable()");
registered_before_rb_global_variable_bignum = LONG2NUM(INT64_MAX);
registered_before_rb_global_variable_bignum = LL2NUM(INT64_MAX);
registered_before_rb_global_variable_float = DBL2NUM(3.14);

registered_after_rb_global_variable_string = rb_str_new_cstr("registered after rb_global_variable()");
rb_global_variable(&registered_after_rb_global_variable_string);
registered_after_rb_global_variable_bignum = LONG2NUM(INT64_MAX);
registered_after_rb_global_variable_bignum = LL2NUM(INT64_MAX);
rb_global_variable(&registered_after_rb_global_variable_bignum);
registered_after_rb_global_variable_float = DBL2NUM(6.28);
rb_global_variable(&registered_after_rb_global_variable_float);
Expand Down

0 comments on commit 23ab41b

Please sign in to comment.