NVHPC compiler gives error with pointer arithmetic
Status: Beta
Brought to you by:
seranian
I'm seeing this error with the 4.14.1 source
nvc -m64 -tp=native -fpic -noswitcherror -Masmkeyword -D__thread='' -mp -lpthread -std=c99 -g -Wall -Werror -Wextra -Wno-unused-parameter -I. -I/usr/local/build/include -DCONFIG_PFMLIB_DEBUG -DCONFIG_PFMLIB_OS_LINUX -DCONFIG_PFMLIB_NOTRACEPOINT -g -Wall -Werror -Wextra -Wno-unused-parameter -I. -I/usr/local/build/lib/../include -DCONFIG_PFMLIB_DEBUG -DCONFIG_PFMLIB_OS_LINUX -DCONFIG_PFMLIB_NOTRACEPOINT -DHAS_OPENAT -D_REENTRANT -I. -fvisibility=hidden -DCONFIG_PFMLIB_ARCH_ARM64 -I. -c pfmlib_common.c
"pfmlib_common.c", line 920: error: arithmetic on pointer to void or function type [nonobject_pointer_arithmetic]
return (pfmlib_pmu_t *)(p - offs);
^
Remark: individual warnings can be suppressed with "--diag_suppress <warning-name>"
1 error detected in the compilation of "pfmlib_common.c".
make[1]: *** [/usr/local/build/lib/../rules.mk:30: pfmlib_common.o] Error 2
make[1]: Leaving directory '/usr/local/build/lib'
make: *** [Makefile:73: install] Error 2
This didn't happen with the 4.13.0 source.
I'm using the NVHPC 26.9 compilers here. Googling around, it suggests that this statement is accepted by GCC but may not be compliant with the C standard. Note that the
-std=c99flag failed to suppress the error.If there's a dimple code substitution I can use, I'd be willing to try it.
4.14.0 has the same problem as 4.14.1.
This is the body in 4.14.1:
So, yeah, it's performing arithmetic between two
void *pointers.I can stop this particular error using the command
which converts the above to
Last edit: Carl Ponder 2 days ago
Ok -- the
-Werrorflag causes the failure here. I assume it's being used precisely to flag this kind of issue: potentially non-portable C.That said, I don't know what the correct source-change would be to fix this, I don't use pointer-arithmetic. For now, I'm just going to suppress the error-flagging: