Open ben-albrecht opened 7 years ago
This works now with LLVM, producing a correct output:
checkModByZeroScope.chpl:7: error: halt reached - Attempt to compute a modulus by zero
Though it still fails the same way with CHPL_LLVM=none
.
The future doesn't pass yet because it has no .bad file, and the good file expects a different error message (and has the filename wrong to boot.)
I'm not sure about even fixing the .good file because then the test will sometimes pass and sometimes fail. Maybe a suppressif? Or splitting the test to an llvm test and a non-llvm future?
I opened #24133 to split the test to one that passes under llvm and one that's a future with the gcc backend.
My preference is that this case produces a compile-time error, analogously by dividing by a "param" zero ex. writeln(x/0)
.
So I propose to repurpose this issue to request a good error message to be issued by our compiler, rather than having it come from the C code.
Summary of Problem
When scoping a modulus-by-zero operation, we get a backend compilation error that looks something like this:
Instead of the expected execution-time error, which you get if you declare the variables on the global scope:
The solution to this likely involves adding special-case checks for
if (rhs == 0)
tocompiler/codegen/expr.cpp
incodegenMod()
andcodegenOpAssign()
for%
and%=
, respectively.Steps to Reproduce
Source Code:
Associated Future Test(s):
test/compflags/checks/checkModByZeroScope.chpl
#6187Configuration Information
gcc --version
orclang --version
:Apple LLVM version 8.0.0 (clang-800.0.42.1)