[ruby-core:90382] [Ruby trunk Bug#15299] hash.c: warning: ‘bin’ may be used uninitialized in this function

From: nobu@...
Date: 2018-12-09 02:32:33 UTC
List: ruby-core #90382
Issue #15299 has been updated by nobu (Nobuyoshi Nakada).


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.

----------------------------------------
Bug #15299: hash.c: warning: ‘bin’ may be used uninitialized in this function
https://bugs.ruby-lang.org/issues/15299#change-75502

* Author: duerst (Martin Dürst)
* Status: Open
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 
* ruby -v: ruby 2.4.0dev (2016-06-09 trunk 55334) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
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.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next