Nvc/21.7 regression: Internal compiler error. Can only coerce indirect args

I have been testing compiling a large mixed C/C++ project with the latest NVHPC release, 21.7. Unfortunately some legacy C code now triggers an ICE from nvc:

NVC++-F-0000-Internal compiler error. Can only coerce indirect args      96  (bug.c: 9)
NVC++/x86-64 Linux 21.7-0: compilation aborted

while at least 21.2 and 21.5 compiled successfully (we have been using the PGI/NVHPC compilers for several years, so I strongly suspect many older versions were also fine).

I tried using C-Reduce to produce a minimal reproducer, and it came up with:

typedef struct {
  double a;
} b;
b *c;
int d;
double e, f;
double g(b);
double h() {
  for (; d; d++)
    f = e ? e : g(c[d]);
  return f;
}

which produces the above error with nvc -O2 -c bug.c using NVHPC/21.7.
In 21.5 this compiles whether or not I pass -O2, in 21.7 it compiles with -O0 or -O1 but not -O2 or -O3.

Is there a straightforward fix/workaround (e.g. a pragma to disable the relevant bit of optimisation)? If not, I can try to disable optimisation for this file. I hope this can be fixed for the next release!

Hi olupton,

Thanks very much for the simple reproducer! It helps our engineers a lot when tracking down these errors.

I was able to reproduce the issue here and have filed a problem report (TPR #30400). It appears to be an issue with the vectorizor so the work around would be to add the flag “-Mnovect”.

Thanks again,
Mat

Thanks for the quick reply Mat!

I confirm that -Mnovect avoids the problem both in the minimal reproducer and the original context.

By the way, appending -O1 did not work:

$ nvc -c bug.c -O2 -O1
nvc-Info-Switch -Mvect forces -O2
NVC++-F-0000-Internal compiler error. Can only coerce indirect args      96  (bug.c: 9)
NVC++/x86-64 Linux 21.7-0: compilation aborted

which is a little annoying because, in CMake-based projects, it’s easier to append flags than it is to replace them, especially on a per-file basis like this. With GCC then -O2 -O0 is the same as -O0.

Cheers, Olli

Hi Olli,

I wanted to let you know that TPR #30400 was fixed in the 21.9 release.

% nvc -c bug.c -V21.7 -fast
NVC++-F-0000-Internal compiler error. Can only coerce indirect args     116  (bug.c: 9)
NVC++/x86-64 Linux 21.7-0: compilation aborted
% nvc -c bug.c -V21.9 -fast
%

Thanks again for the report!
Mat