[Bug fortran/34721] Output statements fool the -Wuninitialized option
manu at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu Jan 10 14:47:00 GMT 2008
------- Comment #1 from manu at gcc dot gnu dot org 2008-01-10 14:07 -------
This is an example that shows that small differences in code lead to quite
different SSA representations. Without print we have a PHI node, where one of
the operands is the uninitialized value, so we warn. However, with the print
statement, we don't generate such PHI node, so we don't warn:
* With the print statement:
# BLOCK 7, starting at line 5
# PRED: 5 (false) 6 (fallthru)
# STORES: { dt_parm.5D.883 }
[pr34721.f90 : 5] dt_parm.5D.883.commonD.821.filenameD.743 ={v}
&"pr34721.f90"[1]{lb: 1 sz: 1};
# STORES: { dt_parm.5D.883 }
[pr34721.f90 : 5] dt_parm.5D.883.commonD.821.lineD.744 ={v} 5;
# STORES: { dt_parm.5D.883 }
[pr34721.f90 : 5] dt_parm.5D.883.commonD.821.flagsD.741 ={v} 128;
# STORES: { dt_parm.5D.883 }
[pr34721.f90 : 5] dt_parm.5D.883.commonD.821.unitD.742 ={v} 6;
[pr34721.f90 : 5] _gfortran_st_write (&dt_parm.5D.883);
[pr34721.f90 : 5] _gfortran_transfer_integer (&dt_parm.5D.883, &nD.872, 4);
<== PASSED BY REFERENCE!!
[pr34721.f90 : 5] _gfortran_st_write_done (&dt_parm.5D.883);
# LOADS: { nD.872 }
[pr34721.f90 : 6] D.884_31 = nD.872; <===== NO PHI NODE!!
[pr34721.f90 : 6] iD.871_32 = 1;
[pr34721.f90 : 6] if (iD.871_32 <= D.884_31)
goto <bb 8>;
else
goto <bb 9>;
# SUCC: 8 (true) 9 (false)
* Without the print statement
# BLOCK 7, starting at line 6
# PRED: 5 (false) 6 (fallthru)
# nD.872_2 = PHI <nD.872_26(D)(5), nD.872_32(6)> <== PHI NODE WITH
UNINITIALIZED VALUE!!
[pr34721.f90 : 6] D.883_33 = nD.872_2;
[pr34721.f90 : 6] iD.871_34 = 1;
[pr34721.f90 : 6] if (iD.871_34 <= D.883_33)
goto <bb 8>;
else
goto <bb 9>;
# SUCC: 8 (true) 9 (false)
I have no idea why "print" generates loads/stores but if the variable is passed
by reference to a function, it is very risky to warn, since the function may
initialize the variable.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-01-10 14:07:44
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34721
More information about the Gcc-bugs
mailing list