Project

General

Profile

Bug #15299

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

Added by duerst (Martin Dürst) 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
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.

Associated revisions

Revision 485f3b57
Added by nobu (Nobuyoshi Nakada) about 1 month ago

Initialize bin

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 66306
Added by nobu (Nobuyoshi Nakada) about 1 month ago

Initialize bin

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

Revision 66306
Added by nobu (Nobuyoshi Nakada) about 1 month ago

Initialize bin

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

History

Updated by nobu (Nobuyoshi Nakada) about 1 month 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) about 1 month 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)

#3

Updated by duerst (Martin Dürst) about 1 month 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]
#4

Updated by nobu (Nobuyoshi Nakada) about 1 month 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]

Also available in: Atom PDF