Bug in nvfortran for mod(i,0)?

Perhaps fixing this is already on the pipeline, but anyway:

When compiling this program:

print*,mod(2,0)
end

with the latest nvfortran, I get:

nvfortran test.f90
nvfortran-Fatal-/opt/nvidia/hpc_sdk/Linux_x86_64/22.7/compilers/bin/tools/fort1 TERMINATED by signal 8
Arguments to /opt/nvidia/hpc_sdk/Linux_x86_64/22.7/compilers/bin/tools/fort1
/opt/nvidia/hpc_sdk/Linux_x86_64/22.7/compilers/bin/tools/fort1 test_stuffs.f90 -opt 1 -terse 1 -inform warn -nostatic -x 19 0x400000 -quad -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -tp skylake-avx512 -x 57 0xfb0000 -x 58 0x78031040 -x 47 0x08 -x 48 4608 -x 49 0x100 -stdinc /opt/nvidia/hpc_sdk/Linux_x86_64/22.7/compilers/include:/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/include:/usr/local/include:/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/include-fixed:/usr/include -cmdline '+nvfortran test_stuffs.f90 ' -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __LP64__ -def __x86_64 -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __amd64 -def __amd64__ -def __k8 -def __k8__ -def __MMX__ -def __SSE__ -def __SSE2__ -def __SSE3__ -def __SSSE3__ -def __ABM__ -def __SSE4_1__ -def __SSE4_2__ -def __AVX__ -def __AVX2__ -def __AVX512F__ -def __AVX512CD__ -def __AVX512VL__ -def __AVX512BW__ -def __AVX512DQ__ -def __F16C__ -def __FMA__ -def __XSAVE__ -def __XSAVEOPT__ -def __XSAVEC__ -def __XSAVES__ -def __POPCNT__ -def __AES__ -def __PCLMUL__ -def __CLFLUSHOPT__ -def __FSGSBASE__ -def __RDRND__ -def __BMI__ -def __BMI2__ -def __LZCNT__ -def __FXSR__ -def __RTM__ -def __PGLLVM__ -def __NVCOMPILER_LLVM__ -def __extension__= -freeform -vect 48 -x 54 1 -x 68 0x1 -x 70 0x40000000 -x 70 0x40000000 -x 68 0x1 -x 124 1 -x 195 0x8000 -y 163 0xc0000000 -x 189 0x10 -stbfile /tmp/nvfortran0TOcC0hRboSj.stb -modexport /tmp/nvfortranuTOc8xgU7uOi.cmod -modindex /tmp/nvfortran0TOcCx5yEvxa.cmdx -cci /tmp/nvfortranuTOc8mwEDQ5R.cci -output /tmp/nvfortran0TOcCbMx6ijC.ilm

Where one would expect a compiler error that the argument shouldn’t be zero?

Yes, it looks like were not checking if the denominator is zero before doing the compile time evaluation. I added a problem report, filed as TPR#32222, and sent to engineering for investigation.

-Mat

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

FYI, TPR #32222 has been fixed in our 22.9 release. The compiler now emits a compilation error if the denominator in mod is detected as being zero:


 % nvfortran test.f90 -V22.9
NVFORTRAN-S-1255-P argument to MOD intrinsic cannot be zero. (test.f90: 1)
  0 inform,   0 warnings,   1 severes, 0 fatal for MAIN