public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/114929] New: for loop fails to iterate down to zero if a cardinal type (unsigned type) is used with a step of -1.
@ 2024-05-02 23:56 gaius at gcc dot gnu.org
  2024-05-02 23:56 ` [Bug modula2/114929] " gaius at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-02 23:56 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-03 22:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-02 23:56 [Bug modula2/114929] New: for loop fails to iterate down to zero if a cardinal type (unsigned type) is used with a step of -1 gaius at gcc dot gnu.org
2024-05-02 23:56 ` [Bug modula2/114929] " gaius at gcc dot gnu.org
2024-05-03  0:01 ` gaius at gcc dot gnu.org
2024-05-03  0:23 ` cvs-commit at gcc dot gnu.org
2024-05-03  0:27 ` gaius at gcc dot gnu.org
2024-05-03 19:48 ` cvs-commit at gcc dot gnu.org
2024-05-03 21:59 ` cvs-commit at gcc dot gnu.org
2024-05-03 22:29 ` gaius at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).