This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 May 2007 21:48:05 -0000
- Subject: [Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
- References: <bug-32132-7667@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from pinskia at gcc dot gnu dot org 2007-05-28 21:48 -------
The warning is correct you need to check if str had an error after reading the
integer. This is not a GCC bug.
The IR looks like:
<bb 7>:
__comp_ctor (&str, s, 8);
this.104 = (struct ios_base *) &str.D.25711;
__s = this.104 + *(int *) (str.D.25711._vptr.basic_istream + -12);
D.40158 = __s->_M_fmtflags;
__s->_M_fmtflags = D.40158 & -57 | 16;
_M_get_num (&str.D.25711, &__lval);
<bb 8>:
if (((this.104 + *(int *) (str.D.25711._vptr.basic_istream +
-12))->_M_iostate & 5) != 0)
goto <bb 10>;
else
goto <bb 9>;
<bb 9>:
__lval.107 = __lval;
r = __lval.107;
<bb 10>:
__comp_dtor (&str);
return r;
Which shows for sure r may be used unitialized.
Note using libstdc++ does not warn about this because we made >> out of line
only which means you will not see the warning (even though the warning is
correct).
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132