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

            Bug ID: 98230
           Summary: Bug in Type'Modulus during a loop whose range is
                    computed by a variable
           Product: gcc
           Version: 8.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: adam at vany dot ca
  Target Milestone: ---

Created attachment 49732
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49732&action=edit
Source code to reproduce

The T'Modulus of a type appears to change during a loop with a computed range.

The bug does not reproduce if the loop has a fixed range (range 1 .. 30 instead
of range 1 .. Max).  It also does not reproduce if T'Mod is not called during
the loop.


==== Output
N:  1 Modulus:     3 Mod: 1
N:  2 Modulus:     3 Mod: 2
N:  3 Modulus:     3 Mod: 3
N:  4 Modulus:     3 Mod: 4
N:  5 Modulus:     3 Mod: 5
N:  6 Modulus:     3 Mod: 6
N:  7 Modulus:     3 Mod: 7
N:  8 Modulus:     3 Mod: 8
N:  9 Modulus:     3 Mod: 9
N:  10 Modulus:    03 Mod: 10
N:  11 Modulus:    13 Mod: 11
N:  12 Modulus:    23 Mod: 12
N:  13 Modulus:    33 Mod: 13
N:  14 Modulus:    43 Mod: 14
N:  15 Modulus:    53 Mod: 15
N:  16 Modulus:    63 Mod: 16
N:  17 Modulus:    73 Mod: 17
N:  18 Modulus:    83 Mod: 18
N:  19 Modulus:    93 Mod: 19
N:  20 Modulus:    03 Mod: 20
N:  21 Modulus:    13 Mod: 21
N:  22 Modulus:    23 Mod: 22
N:  23 Modulus:    33 Mod: 23
N:  24 Modulus:    43 Mod: 24
N:  25 Modulus:    53 Mod: 25
N:  26 Modulus:    63 Mod: 26
N:  27 Modulus:    73 Mod: 27
N:  28 Modulus:    83 Mod: 28
N:  29 Modulus:    93 Mod: 29
N:  30 Modulus:    03 Mod: 30

=== Expected output
Modulus should not change, it should always be 3, Mod: should always stay in
the range 0-3.

If the loop is change to 1 .. 30, instead of 1 .. Max, it works as expected.

Reply via email to