Bug #11479
closedgcc warning variable may be used uninitialized
Description
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
Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago
- 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.