DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B8006: when others does not handle failed checks

Catalog status: active. Default severity: warning. Stable name: others-handler-checks. Family: Warnings and assumptions.

In Ada, when others also catches Constraint_Error from a failed check. In Verada a failed check is not an exception: checks are proved, and in a build without proof a failed check stops the program (see the Language Reference). So when others handles only the exceptions the program raises itself, and this warning says so where its meaning differs from GNAT's.

Example (Vada)

begin
   Take (N);
exception
   when others =>   --  Take's exceptions, not failed checks
      Put_Line ("nothing to take");
end Main;

Example (Varc)

    try {
        Take(&N);
    } catch {   // Take's exceptions, not failed checks
        Put_Line("nothing to take");
    }

What to do

Name the exceptions the handler is for, so that the warning goes away and the handler says what it handles. A program that needs to survive a failed check should prove the check instead.

Regression source and further reading

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

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