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.

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 :-)

Reply via email to