[ruby-cvs:72732] shyouhei:r65632 (trunk): hash.c: +(-1) is a wrong idea

shyouhei at ruby-lang.org shyouhei at ruby-lang.org
Thu Nov 8 16:41:25 JST 2018


shyouhei	2018-11-08 16:41:24 +0900 (Thu, 08 Nov 2018)

  New Revision: 65632

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65632

  Log:
    hash.c: +(-1) is a wrong idea
    
    Before this changeset RHASH_ARRAY_SIZE_DEC() was expaneded to include
    an expression like `RHASH_ARRAY_SIZE+(-1)`.  RHASH_ARRAY_SIZE is by
    definition unsigned int.  -1 is signed, of course.  Adding a signed
    and an unsigned value requires the "usual arithmetic conversions" (cf:
    ISO/IEC 9899:1990 section 6.2.1.5).  -1 is converted to 0xFFFF by that.
    
    This patch prevents that conversion.

  Modified files:
    trunk/hash.c


More information about the ruby-cvs mailing list