https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117861

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|pragma Suppress             |internal error on
                   |(Overflow_check) is ignored |range/overflow check
                   |and overflow fails at       |suppression for static
                   |compilation rather than     |expression
                   |throwing an exception       |
             Status|UNCONFIRMED                 |NEW
                 CC|                            |ebotcazou at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-12-03

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> While a table is unlikely to have Positive'Last as an index, it could be
> indexed with Boolean, so the last iteration of the loop WILL necessarily
> causes overflow. It should normally trigger a Constraint_Error, that I can
> catch, but I want to suppress the check instead. But `A := Integer'Succ
> (A);` is straight up refused.

No, that's a C-like reasoning, idiomatic loops in Ada never overflow their
index and, therefore, people should never fiddle with overflow checks:

procedure P is

  type Arr is array (Positive) of Boolean;

  Table : Arr;

begin
  for J in Table'Range loop
    Table (J) := True;
  end loop;
end;

works just fine.  That being said, the compiler should accept the code.

Reply via email to