[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #12 from pinskia at gcc dot gnu dot org 2007-06-10 03:18 --- It should never result in more warnings. More inlining :) Anyways the use is still uninitialized if you look at the IR, GCC itself cannot tell if r is initialized by looking at the IR. -- 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
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #6 from pluto at agmk dot net 2007-05-29 08:50 --- (In reply to comment #5) Which shows for sure r may be used unitialized. yes, but even if i catch possible i/o failure, gcc still produces warning. --- auHexCastTest.ii.orig +++ auHexCastTest.ii @@ -18958,7 +18958,12 @@ R r; stlp_std::istringstream str ( s ); - str stlp_std::hex r; + str.exceptions ( stlp_std::istringstream::eofbit || stlp_std::istringstream::badbit || stlp_std::istringstream::failbit ); + try { +str stlp_std::hex r; + } catch ( stlp_std::istringstream::failure ) { +throw; + } return r; } so, is it still an invalid testcase? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #7 from pluto at agmk dot net 2007-05-29 10:17 --- (In reply to comment #6) + str.exceptions ( stlp_std::istringstream::eofbit || stlp_std::istringstream::badbit || stlp_std::istringstream::failbit ); of course it should be '|' instead of '||' (shame on me) but the warning is still presents. it is also presents when i use the fail() method instead of exceptions machinery. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #8 from manu at gcc dot gnu dot org 2007-05-29 12:31 --- (In reply to comment #6) so, is it still an invalid testcase? Does the warning show up with -O1 and -O2 ? -- manu at gcc dot gnu dot org changed: What|Removed |Added CC||manu at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #9 from pluto at agmk dot net 2007-05-29 12:35 --- (In reply to comment #8) (In reply to comment #6) so, is it still an invalid testcase? Does the warning show up with -O1 and -O2 ? only with -O3. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #10 from pluto at agmk dot net 2007-05-29 12:42 --- Created an attachment (id=13627) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13627action=view) update for the testcase. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #11 from manu at gcc dot gnu dot org 2007-05-29 12:57 --- (In reply to comment #9) (In reply to comment #8) (In reply to comment #6) so, is it still an invalid testcase? Does the warning show up with -O1 and -O2 ? only with -O3. That is a bug by itself. Using more optimisations could result in some cases clearing out (and thus, less warnings). It should never result in more warnings. -- manu at gcc dot gnu dot org changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #1 from pluto at agmk dot net 2007-05-28 20:08 --- Created an attachment (id=13623) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13623action=view) testcase -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #2 from pinskia at gcc dot gnu dot org 2007-05-28 20:13 --- This might not be a bug -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #3 from pluto at agmk dot net 2007-05-28 20:16 --- (In reply to comment #2) This might not be a bug so, how 'r' can be used uninitialized in this case? template typename R R hex_cast ( const std::string s ) { if ( s.empty () ) throw bad_hex_cast (); R r; std::istringstream str ( s ); str std::hex r; return r; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- Comment #4 from pinskia at gcc dot gnu dot org 2007-05-28 20:26 --- so, how 'r' can be used uninitialized in this case? Because istringstream r could have caused an error. so you need to check if there is an error. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32132
[Bug c++/32132] bogus warning at -O3 ( 'r' may be used uninitialized in this function ).
--- 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