------- Comment #5 from manu at gcc dot gnu dot org  2009-02-07 16:18 -------
This is an interaction between SRA deciding to create separate variables for
testval and unusedval because of the copy and DCE deciding whether to remove
all references to unusedval because of the call.

The copy is an use, but if the result is not used, then DCE removes it and the
warning goes away. If you pass something to a function, that is an use. In
particular, the BLOCK is not conditional and there is no PHI node: so the
uninitialized value "is used". GCC does not warn for forget(testvar) because
SRA is not applied there and hence GCC does not know whether elements of
testvar are uninitialized.

Ideally, we should warn in all cases or in none. I would rather warn in all
cases as we do for simple variables. If testvar is completely uninitialized and
passed to a function, we should definitely get a warning.

Anyway, this will be hard to get right because we would need to look within
structures. This is more an enhancement request.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-02-07 16:18:20
               date|                            |
            Summary|invalid "is" used           |inconsistent uninitialized
                   |uninitialized, should be    |warning  for structs (SRA,
                   |"may be"                    |DCE)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22197

Reply via email to