Unreachable Code

| SimCon Home | fpt Reference Manual Home |

Does Unreachable Code Always Imply a Problem?

No. Fortran parameters and #if - #elif - #endif chains may be used to switch sections of code into and out of the executable paths, and the unused code may remain in place. However, code does sometimes become inaccessible by accident.

Detection of Unreachable Code

fpt analyses the program flow and finds all of the non-branching sequences of statements. It then determines all of the routes to and from every sequence. If there are no routes to a sequence it is unreachable.

fpt always analyses the program flow, but will not mark unreachable statements unless instructed to do so. The command is:

CHECK PROGRAM FLOW

fpt generates a diagnostic for every unreachable sequence, and writes a count of the number of unreachable sequences found. The end of a report from a tracking radar control code is shown below:

Sequence: 18251, 2 executable statements at Line: 807 File: ...est/long_test_suites/trmsc_052/source/2prem/modified_source/urpme111.f Notes: Unreachable ELSE Sequence: 18284, 1 executable statement at Line: 1012 File: ...est/long_test_suites/trmsc_052/source/2prem/modified_source/urpme111.f Notes: Unreachable ELSEIF (istatus4 .EQ. p_stop) THEN Sequence: 18285, 1 executable statement at Line: 1013 File: ...est/long_test_suites/trmsc_052/source/2prem/modified_source/urpme111.f Notes: Unreachable start = .FALSE. Sequence: 18286, 2 executable statements at Line: 1016 File: ...est/long_test_suites/trmsc_052/source/2prem/modified_source/urpme111.f Notes: Unreachable ELSE Sequence: 19603, 3 executable statements at Line: 186 File: /home/john/fpt/adbserve/acl_lib/acnewl.for Notes: Unreachable 4552 CONTINUE 2350 un-reachable code sequences (Warnings)

fpt also writes a diagnostic into the code at the first statement of each unreachable sequence, for example (Again from the tracking radar):

! ! CYC_WITHOUT_SAMPLING_DATA: ! -------------------------- ! FPT CASE 2 ELSEIF (icyc_c_typ .EQ. 2) THEN !--------------^--------------------------------------------------------------- !!! FPT - 2715 This executable statement is un-reachable !------------------------------------------------------------------------------ ! ! HANDLE ERRORS RECEIVING FROM WAIT FOR TIMER ! -------------------------------------------- CALL sr_statget ! RETURN IIEVSTAT TO DATAPOOL ! !--------------^--------------------------------------------------------------- !!! FPT - 2715 This executable statement is un-reachable !------------------------------------------------------------------------------ CALL sr_err(crit_err)

Copyright ©1995 to 2024 Software Validation Ltd. All rights reserved.