Project

General

Profile

Actions

Bug #15299

closed

hash.c: warning: ‘bin’ may be used uninitialized in this function

Added by duerst (Martin Dürst) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.0dev (2018-12-09 trunk 66296) [x86_64-linux]
[ruby-core:89780]

Description

When compiling the latest version of trunk, I get some warnings in hash.c, as follows:

compiling hash.c
hash.c: In function ‘linear_update’:
hash.c:849:24: warning: ‘bin’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             clear_entry(RHASH_ARRAY_REF(hash, bin));
                        ^
hash.c: In function ‘rb_hash_stlike_update’:
hash.c:849:24: warning: ‘bin’ may be used uninitialized in this function [-Wmaybe-uninitialized]
hash.c:811:14: note: ‘bin’ was declared here
     unsigned bin;
              ^

This warning appeared already when I reported issue #15279, but I didn't mention it because I hoped it would also disappear when #15279 was fixed.

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

What version of cc?

It is a false warning.

bin is initialized if the hash is not empty, and otherwise existing is FALSE.
And the line is in a block of if (existing), so unintialized bin never reaches there.

Updated by duerst (Martin Dürst) over 5 years ago

nobu (Nobuyoshi Nakada) wrote:

What version of cc?

[duerst@stazersee ruby2]$ gcc --version
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)

Actions #3

Updated by duerst (Martin Dürst) over 5 years ago

  • ruby -v changed from ruby 2.4.0dev (2016-06-09 trunk 55334) [x86_64-linux] to ruby 2.6.0dev (2018-12-09 trunk 66296) [x86_64-linux]
Actions #4

Updated by nobu (Nobuyoshi Nakada) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r66306.


Initialize bin

  • hash.c (linear_update): initialize bin just to silence false
    warnings by old gcc 4.8. [Bug #15299]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0