From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.2 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 87FEC1F453 for ; Sun, 20 Jan 2019 21:21:55 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 541A012158D; Mon, 21 Jan 2019 06:21:52 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id B5A66121443 for ; Mon, 21 Jan 2019 06:21:49 +0900 (JST) Received: by filter0057p3mdw1.sendgrid.net with SMTP id filter0057p3mdw1-1075-5C44E66A-34 2019-01-20 21:21:47.016093037 +0000 UTC m=+501268.106022476 Received: from herokuapp.com (ec2-54-205-253-189.compute-1.amazonaws.com [54.205.253.189]) by ismtpd0034p1iad2.sendgrid.net (SG) with ESMTP id 3XT6lyeCRMWsekPg5DPH6w for ; Sun, 20 Jan 2019 21:21:46.981 +0000 (UTC) Date: Sun, 20 Jan 2019 21:21:48 +0000 (UTC) From: eregontp@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66643 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15551 X-Redmine-Issue-Author: Eregon X-Redmine-Sender: Eregon X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS70tlxAyMfR6G1mfY5hICbySA6XU2izZeI4ed XVIS6FeKYIjv9jqktA3mDTg/oPY+02eYypV1qxeP6oQ2h/7/qPb3Bp7Zr1uccLEJTYv0tzbJ++CCrB jiv+TYB9MO5A8TPekFLy0ltO8FFNO92ElXzdGHO2Muw92fIZw8axRNNkog== X-ML-Name: ruby-core X-Mail-Count: 91196 Subject: [ruby-core:91196] [Ruby trunk Bug#15551] The behavior of FIX2INT and FIX2UINT differs by platform X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15551 has been updated by Eregon (Benoit Daloze). FWIW, `sizeof(int) == sizeof(long)` is also the case on i686 Linux: https://travis-ci.org/ruby/ruby/jobs/482143545 ---------------------------------------- Bug #15551: The behavior of FIX2INT and FIX2UINT differs by platform https://bugs.ruby-lang.org/issues/15551#change-76428 * Author: Eregon (Benoit Daloze) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.4.5p335 (2018-10-18 revision 65137) [x64-mingw32] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- For instance, when `sizeof(int) < sizeof(long)` (such as on Linux), then ```c FIX2INT(nil) ``` raises TypeError. But when `sizeof(int) == sizeof(long)` (such as on Windows), then it returns `4`. So the behavior changes from a call to `rb_fix2int()` to a raw shift without any checks. I think it should be consistent between platforms. Also, the code in ruby.h defining FIX2INT is fairly complicated with conditions like `#if SIZEOF_INT < SIZEOF_LONG` spanning many lines, which makes it fairly hard to follow. See https://github.com/ruby/spec/blob/c661c0ba6a602be6e06768a319bd7d87b2a8eda6/optional/capi/fixnum_spec.rb and https://ci.appveyor.com/project/eregon/spec-x948i/builds/21753809/job/ed8e8k97m8syp4r7 for more differences. -- https://bugs.ruby-lang.org/