chapel
chapel copied to clipboard
comparisons between uint and 0 aren't folded by the compiler
Feature request
Summary of Problem
Given a comparison between a uint and 0 that is known to always be true by definition such as 'a > 0' or 'a >= 0', I believe the compiler should param fold this conditional as it does with other obvious facts. It doesn't currently at present because the overload that handles this case returns 'true' along one branch (when the other arg is a param 0) and calls the execution time comparison in the other branch; so the routine can't be a param routine and can't be folded.
A potential fix is to break the routine into two using a where clause to disambiguate and making the obvious case a param function and the other case not. But this runs into bugs in our handling of where clauses which is another issue (#5236).
Steps to Reproduce
Source Code:
config var x: uint;
if (x < 0) then
compilerError("This should never happen");
Compile command:
chpl foo.chpl
Execution command:
./a.out
Configuration Information
- Output of
chpl --version
: 1.14.0.a771ec7 - Output of
$CHPL_HOME/util/printchplenv --anonymize
: N/A - Back-end compiler and version, e.g.
gcc --version
orclang --version
: N/A - (For Cray systems only) Output of
module list
: N/A