https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114929
Bug ID: 114929 Summary: for loop fails to iterate down to zero if a cardinal type (unsigned type) is used with a step of -1. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: gaius at gcc dot gnu.org Target Milestone: --- An example of the bug follows: MODULE testforloopzero ; FROM libc IMPORT printf, exit ; (* test - *) PROCEDURE test ; VAR i, n, count: CARDINAL ; BEGIN n := 5 ; count := 0 ; FOR i := n TO 0 BY -1 DO printf ("i = %d, count = %d\n", i, count); INC (count) END ; IF count = 6 THEN printf ("for loop counting down passed\n") ELSE printf ("for loop counting down failed\n") ; exit (1) END END test ; BEGIN test END testforloopzero. $ gm2 testforloopzero.mod $ ./a.out i = 5, count = 0 for loop counting down failed