https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71674
Bug ID: 71674 Summary: An exception is thrown on a valid code Product: gcc Version: 6.1.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: ada Assignee: unassigned at gcc dot gnu.org Reporter: porton at narod dot ru Target Milestone: --- The following valid code throws an exception: -- test_count.adb start with Ada.Strings.Fixed, Ada.Integer_Text_IO; use Ada.Strings.Fixed, Ada.Integer_Text_IO; procedure Test_Count is S : constant String (Positive'Last - 2 .. Positive'Last) := "Ada"; begin Put (Count (Source =>S, Pattern =>"AA")); Put (Count (Source =>S (S'First .. S'Last - 1), Pattern =>"A")); Put (Count (Source =>S, Pattern =>"A")); end; -- test_count.adb end Here is the program run: $ ./test_count 0 1 raised STORAGE_ERROR : stack overflow or erroneous memory access I mark severity minor, because this error is unlikely to appear in a real code. When fixing this bug, attention should be taken not to make new code much slower than the existing code.