Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop while looping in range uint32.low..uint32.high #24470

Open
ovenpasta opened this issue Nov 23, 2024 · 1 comment
Open

Infinite loop while looping in range uint32.low..uint32.high #24470

ovenpasta opened this issue Nov 23, 2024 · 1 comment

Comments

@ovenpasta
Copy link

Description

import std/strutils

for i in uint32.low..uint32.high:
  if i mod 0x10000000'u32 == 0:
    echo i.toHex

Nim Version

Nim Compiler Version 2.2.0 [Linux: amd64]
Compiled at 2024-10-02
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 78983f1
active boot switches: -d:release

Current Output

00000000
10000000
20000000
30000000
40000000
50000000
60000000
70000000
80000000
90000000
A0000000
B0000000
C0000000
D0000000
E0000000
F0000000
00000000
10000000
20000000
30000000
40000000
50000000
60000000
70000000
80000000
90000000
A0000000
B0000000
C0000000
D0000000
E0000000
F0000000
00000000
10000000
20000000
30000000
40000000
50000000
60000000
70000000
80000000
90000000
A0000000
B0000000
C0000000
D0000000
E0000000
F0000000
00000000
10000000
20000000
30000000
40000000
50000000
60000000
70000000
80000000
90000000
A0000000
B0000000
C0000000
D0000000
E0000000
F0000000
00000000
10000000
20000000
30000000
40000000
50000000
60000000
70000000
80000000
90000000
A0000000
B0000000
C0000000
D0000000
E0000000
F0000000
00000000
10000000
20000000
30000000
40000000
50000000
60000000
70000000
80000000
90000000
A0000000
B0000000
C0000000
D0000000
E0000000
F0000000
................ infinite

Expected Output

00000000
10000000
20000000
30000000
40000000
50000000
60000000
70000000
80000000
90000000
A0000000
B0000000
C0000000
D0000000
E0000000
F0000000

Known Workarounds

import std/strutils

for i in 0..uint32.high:
  if i mod 0x10000000'u32 == 0:
    echo i.toHex
  if i == uint32.high:
    break

Additional Information

No response

@metagn
Copy link
Collaborator

metagn commented Nov 23, 2024

Related #16353 #19652

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants