[Bug c/40635] bogus name and location in 'may be used uninitialized' warning
manu at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Jul 6 13:19:00 GMT 2009
------- Comment #2 from manu at gcc dot gnu dot org 2009-07-06 13:19 -------
The root cause is a combination of inline and copy-rename. Copy rename has the
following code:
/* Never attempt to coalesce 2 user variables unless one is an inline
variable. */
if (!ign1 && !ign2)
{
if (DECL_FROM_INLINE (root2))
ign2 = true;
else if (DECL_FROM_INLINE (root1))
ign1 = true;
else
{
if (debug)
fprintf (debug, " : 2 different USER vars. No coalesce.\n");
return false;
}
}
/* If both values have default defs, we can't coalesce. If only one has a
tag, make sure that variable is the new root partition. */
if (gimple_default_def (cfun, root1))
{
if (gimple_default_def (cfun, root2))
{
if (debug)
fprintf (debug, " : 2 default defs. No coalesce.\n");
return false;
}
else
{
ign2 = true;
ign1 = false;
}
}
else if (gimple_default_def (cfun, root2))
{
ign1 = true;
ign2 = false;
}
The net result is that when it combines sockt_rd with s42, it favours s42. This
is the reason it prints s42. However, the location printed corresponds to the
statement:
if (sockt_rd < 0)
return -1;
Then, warn_uninit is not able to detect that this comes from some inlined
thing. If we do this:
- location = (context != NULL && gimple_has_location (context))
+ location = (!DECL_FROM_INLINE (var) && context != NULL
+ && gimple_has_location (context))
? gimple_location (context)
- : DECL_SOURCE_LOCATION (var);
+ : DECL_SOURCE_LOCATION (DECL_ORIGIN (var));
Then we get the right location (line, column) but still the wrong function. I
am not sure how to force the diagnostics machinery to display the correct
function.
--
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 |2009-07-06 13:19:06
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40635
More information about the Gcc-bugs
mailing list