DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B5121: a subprogram might end otherwise than its exit cases say

Catalog status: active. Default severity: error. Stable name: exit-case. Family: Contracts and termination.

Exit_Cases divides a subprogram's entry states by guards and says, for each, how the subprogram ends: Normal_Return, Exception_Raised (or (Exception_Raised => E)), or Program_Exit. Verada proves that no two guards other than others hold at once, and that wherever the subprogram returns, propagates an exception or exits the program, the case whose guard held on entry allows that end.

Example (Vada)

   procedure Maybe_Quit (Code : Integer)
     with Program_Exit,
          Exit_Cases => (Code > 0 => Normal_Return, others => Normal_Return);
   ...
      if Code > 3 then
         GNAT.OS_Lib.OS_Exit (Code);
      end if;

What to do (Vada)

Make the cases say what the body does:

     with Program_Exit,
          Exit_Cases => (Code > 3 => Program_Exit, others => Normal_Return);

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See contracts and termination, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.