[ruby-core:93520] [Ruby master Bug#11479] gcc warning variable may be used uninitialized

From: merch-redmine@...
Date: 2019-07-03 21:34:56 UTC
List: ruby-core #93520
Issue #11479 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

I think the vsnprintf.c issue is spurious, even in 2.2.3. I can't see a case were `uqval` isn't set and line 1074 is reached. case `x`/`X` sets it in line 1041. case `d`/`D` sets on line 846. case `u`/`U` sets it on line 1027. case `o`/`O` sets it on line 969.  case `p` sets it on line 985 if `_HAVE_LLP64_` is defined, and if `_HAVE_LLP64_` is not defined, then it unsets the `QUADINT` flag on line 990, making it so line 1074 is not reached.

It appears the same is true for string.c in 2.2.3. `ary` is set in line 6857 if a block is not given.  If a block is given, it is set in line 6848 if `STRING_ENUMERATORS_WANTARRAY` is true, and otherwise `wantarray` is set to `0` on line 6851 and line 6879 would not be reached.  In any case, `rb_str_enumerate_chars` now takes `ary` as an argument, so the issue shouldn't apply to the master branch in any case.

It looks like there are a lot of bugs in GCC maybe-uninitialized (https://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=maybe%20uninitialized), so I think these are both false-positive compiler warnings.

----------------------------------------
Bug #11479: gcc warning variable may be used uninitialized
https://bugs.ruby-lang.org/issues/11479#change-79081

* Author: zufuliu (Zufu Liu)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [i386-mingw32]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
build ruby-2.2.3 on Windows XP using gcc-5.1.0 generates tow warnings:

compiling signal.c
compiling sprintf.c
In file included from sprintf.c:1255:0:
vsnprintf.c: In function 'BSD_vfprintf':
vsnprintf.c:1074:15: warning: 'uqval' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if (uqval != 0 || prec != 0)
               ^
compiling st.c
compiling strftime.c
compiling string.c
string.c: In function 'rb_str_enumerate_chars':
string.c:6879:3: warning: 'ary' may be used uninitialized in this function [-Wmaybe-uninitialized]
   rb_ary_push(ary, substr);
   ^

gcc:
 gcc version 5.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)

build procedure:
./configure
mingw32-make



---Files--------------------------------
config.h (7.07 KB)


-- 
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