20048, "cassella", "Assymetry in iterating over 0:uint..10 by 1 or -1", "2022-06-21T00:32:19Z"
Summary of Problem
As requested in #19991 comment
Iterating over this range by 1
works fine,
for i in 0:uint..10 by 1 do writeln(i);
but iterating over it by -1
reports an overflow problem:
$CHPL_HOME/modules/internal/ChapelRange.chpl:1918: error: halt reached - Iteration over a bounded range may be incorrect due to overflow.
This asymmetry is unsatisfying.
(Though it does run correctly with --fast
.)
Possibly if the underlying C for loop used !=
instead of <
to break out of the loop, this could be handled. Though @ronawho said there are good reasons for not doing this.
Associated Future Test(s):
None yet
Configuration Information
chpl version 1.27.0 pre-release (d8c48efbee)
CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native *
CHPL_LOCALE_MODEL: flat
CHPL_COMM: gasnet *
CHPL_COMM_SUBSTRATE: udp
CHPL_GASNET_SEGMENT: everything
CHPL_TASKS: qthreads
CHPL_LAUNCHER: amudprun
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_ATOMICS: cstdlib
CHPL_NETWORK_ATOMICS: none
CHPL_GMP: none
CHPL_HWLOC: bundled
CHPL_RE2: bundled
CHPL_LLVM: unset
CHPL_AUX_FILESYS: none
gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0