This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libfortran/79956] [7 Regression] many new -Wmaybe-uninitialized warnings with bootstrap-O3


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79956

--- Comment #27 from rguenther at suse dot de <rguenther at suse dot de> ---
On Sun, 12 Mar 2017, tkoenig at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79956
> 
> --- Comment #24 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
> I think the warning about estat is a gcc bug.
> 
> Here is the function in its entirety:
> 
> void
> execute_command_line_i4 (const char *command, GFC_LOGICAL_4 *wait,
>                          GFC_INTEGER_4 *exitstat, GFC_INTEGER_4 *cmdstat,
>                          char *cmdmsg, gfc_charlen_type command_len,
>                          gfc_charlen_type cmdmsg_len)
> {
>   bool w = wait ? *wait : true;
>   int estat, estat_initial, cstat;
> 
>   if (exitstat)
>     estat_initial = estat = *exitstat;
> 
>   execute_command_line (command, w, &estat, cmdstat ? &cstat : NULL,
>                         cmdmsg, command_len, cmdmsg_len);
> 
>   if (exitstat && estat != estat_initial)
>     *exitstat = estat;
>   if (cmdstat)
>     *cmdstat = cstat;
> }
> 
> estat gets a value if exitstat is non-NULL.  There is nothing
> in the code that could legally change the value of exitstat,
> and the value of estat is only used on the condition that
> exitstat is non-NULL.

You are right.  I've seen a few other cases where odd jump-threading
managed to isolate an obviously dead path through the CFG which is
enough to confuse the warning.

> If anything, second test is unnecessary, and this could be
> shortened to
> 
>   if (exitstat)
>     estat_initial = estat = *exitstat;
> 
>   execute_command_line (command, w, &estat, cmdstat ? &cstat : NULL,
>                         cmdmsg, command_len, cmdmsg_len);
> 
>   if (exitstat)
>     *exitstat = estat;
> 
> Does this fix the warning, by any chance?  This would be quite
> elegant :-)

Indeed - looking at the code you wonder what that estat_initial
is about -- it's just extra state that needs to be kept alive
across the execute_command_line function call to avoid writing
to *exitstat.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]