https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82962
Bug ID: 82962 Summary: valgrind reports "Conditional jump or move depends on uninitialised value" in EXECUTE_COMMAND_LINE Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: janus at gcc dot gnu.org Target Milestone: --- Test case: integer :: istat ! istat = 0 call execute_command_line('echo "Hello World!"', exitstat=istat) end After compiling this with gfortran, and running the resulting executable through valgrind, I get: ==16313== Conditional jump or move depends on uninitialised value(s) ==16313== at 0x4F3B7EA: _gfortran_execute_command_line_i4 (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0) This only occurs if an EXITSTAT argument is passed, which is not initialized before the call. However, EXITSTAT is supposed to be an output argument AFAIK. I don't see why its value should be used at all inside of EXECUTE_COMMAND_LINE? A dump of the program shows: MAIN__ () { integer(kind=4) istat; _gfortran_execute_command_line_i4 (&"echo \"Hello World!\""[1]{lb: 1 sz: 1}, 0B, &istat, 0B, 0B, 19, 0); } Looking at libgfortran/intrinsics/execute_command_line.c, I see the following in execute_command_line_i4: 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; Apparenly the existat after the call is compared to the initial exitstat, which can be uninitialized. I guess it would be better to set exitstat to some defined initial value, instead of using the input value from outside.