From: "simpliandy (Andy Pfister) via ruby-core" Date: 2024-02-16T09:55:58+00:00 Subject: [ruby-core:116795] [Ruby master Bug#20269] bignum too big to convert into `long' when running String#byteslice on Windows Issue #20269 has been updated by simpliandy (Andy Pfister). many thanks for your reply. I found an explanation on [Reddit](https://www.reddit.com/r/C_Programming/comments/4kjd0c/comment/d3fd0vp/). The reason it works on Linux / Mac is that the compiler expands `long` to 64-bit if running on a 64-bit system. I was not aware of this. On Windows, there is a type called [longlong](https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types) which would be 64-bit. not sure if there is a way to say "hey, when compiling Ruby on Windows and on a 64-bit machine, use `longlong` instead of `long`". not even sure if this is a smart idea at all. ---------------------------------------- Bug #20269: bignum too big to convert into `long' when running String#byteslice on Windows https://bugs.ruby-lang.org/issues/20269#change-106818 * Author: simpliandy (Andy Pfister) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x64-mingw-ucrt] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Running `String#byteslice` on Ruby 3.3 on Windows results in an error when using any number bigger than 32 bits: ``` "".byteslice(0, 2547483647) (irb):1:in `byteslice': bignum too big to convert into `long' (RangeError) from (irb):1:in `
' from :187:in `loop' from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/irb-1.11.0/exe/irb:9:in `' from C:/Ruby33-x64/bin/irb:33:in `load' from C:/Ruby33-x64/bin/irb:33:in `
' ``` It works fine on MacOS: ``` irb(main):001> "".byteslice(0, 2547483647) => "" irb(main):002> exit Andys-MBP:project apf$ ruby -v ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23] ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/