Project

General

Profile

Cleanup #1847

Eliminate sources of various compiler warnings

Added by Sam White 4 months ago. Updated 3 months ago.

Status:
Merged
Priority:
Normal
Assignee:
Category:
-
Target version:
Start date:
04/06/2018
Due date:
% Done:

90%


Description

Looking over autobuild I see a lot compiler warnings, some of which were added recently, that should be easily removed:

string.c: In function 'gk_str2time': string.c:511:7:
warning: implicit declaration of function 'strptime' [-Wimplicit-function-declaration]
if (strptime(str, "%m/%d/%Y %H:%M:%S", &time) == NULL)

string.c:511:49: warning: comparison between pointer and integer
if (strptime(str, "%m/%d/%Y %H:%M:%S", &time) == NULL)
machine-common-core.c: In function 'CmiAbort':
machine-common-core.c:1692:1: warning: 'noreturn' function does return

machine.c: In function 'LrtsAbort':
machine.c:562:1: warning: 'noreturn' function does return
msgalloc.C(123): warning C4291: 'void *CMessage_CkMarshallMsg::operator new(std::size_t,int,const int,const GroupDepNum)':
no matching operator delete found; memory will not be freed if initialization throws an exception
cpuaffinity.c: In function 'CmiInitCPUAffinityUtil':
cpuaffinity.c:1272:20: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat=]
sprintf(fname, "/proc/%d/task/%d/stat", getpid(), syscall(SYS_gettid));
isomalloc.c: In function 'init_ranges':
isomalloc.c:1861:13: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
isomalloc.c:1862:13: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
isomalloc.c:1984:21: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
isomalloc.c:1985:21: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
machine-cma.c: In function 'readShmCma':
machine-cma.c:53:15: warning: implicit declaration of function 'process_vm_readv' [-Wimplicit-function-declaration]
   int nread = process_vm_readv(remote_pid, local, numOps, remote, numOps, 0);

machine-cma.c: In function 'writeShmCma':
machine-cma.c:71:15: warning: implicit declaration of function 'process_vm_writev' [-Wimplicit-function-declaration]
   int nread = process_vm_writev(remote_pid, local, numOps, remote, numOps, 0);
../bin/charmc -optimize -production -I. -c -o convcore.o convcore.c convcore.c(3187):
warning #266: function "LrtsRdmaFree" declared implicitly LrtsRdmaFree(BLKSTART(parentBlk)); 

In tests/charm++/megatest:

groupdependence.C:320:51: warning: extra ';' [-Wpedantic]

In tests/charm++/sdag/template:

pgm.C:9:17: warning: extra ';' [-Wpedantic]
pgm.C:21:19: warning: extra ';' [-Wpedantic]

In tests/charm++/sdag/case:

caseTest.C:4:17: warning: extra ';' [-Wpedantic]

In tests/charm++/method_templates:

pgm.C:18:2: warning: extra ';' [-Wpedantic]

In tests/charm++/startupTest:

startupTest.C:174:2: warning: extra ';' [-Wpedantic]
startupTest.C:194:2: warning: extra ';' [-Wpedantic]
startupTest.C:208:2: warning: extra ';' [-Wpedantic]
startupTest.C:214:2: warning: extra ';' [-Wpedantic]
startupTest.C:220:2: warning: extra ';' [-Wpedantic]
startupTest.C:226:2: warning: extra ';' [-Wpedantic]
startupTest.C:232:2: warning: extra ';' [-Wpedantic]
startupTest.C:240:2: warning: extra ';' [-Wpedantic]
startupTest.C:249:2: warning: extra ';' [-Wpedantic]
startupTest.C:258:2: warning: extra ';' [-Wpedantic]
startupTest.C:277:2: warning: extra ';' [-Wpedantic]

In tests/charm++/reductionTesting/reductionTesting1D (same for 2D and 3D):

Main.C:10:4: warning: extra ';' [-Wpedantic]
Main.C:13:3: warning: extra ';' [-Wpedantic]
Main.C:46:2: warning: extra ';' [-Wpedantic]
Main.C:59:2: warning: extra ';' [-Wpedantic]
Main.C:94:2: warning: extra ';' [-Wpedantic]
sectionReduction.C:8:2: warning: extra ';' [-Wpedantic]
sectionReduction.C:11:4: warning: extra ';' [-Wpedantic]
sectionReduction.C:55:2: warning: extra ';' [-Wpedantic]

Windows:

machine-smp.c(153): warning C4311: 'type cast': pointer truncation from 'LPVOID' to 'int'
machine-smp.c(233): warning C4312: 'type cast': conversion from 'int' to 'LPVOID' of greater size

ckarray.C(431): warning C4312: 'type cast': conversion from 'unsigned int' to 'CkArray *' of greater size
pup_cmialloc.C(68): warning C4311: 'type cast': pointer truncation from 'PUP::myByte *' to 'long'
pup_cmialloc.C(68): warning C4312: 'type cast': conversion from 'long' to 'PUP::myByte *' of greater size
ckhashtable.C(368): warning C4005: 'CDECL': macro redefinition
C:\Program Files (x86)\Windows Kits\8.1\include\shared\minwindef.h(111): note: see previous definition of 'CDECL'
packf77.C(5): warning C4311: 'type cast': pointer truncation from 'Packer *' to 'long'
packf77.C(10): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(15): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(20): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(25): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(30): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(35): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(40): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(45): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(50): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(55): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(60): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(65): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(70): warning C4312: 'type cast': conversion from 'long' to 'Packer *' of greater size
packf77.C(75): warning C4311: 'type cast': pointer truncation from 'Unpacker *' to 'long'
packf77.C(80): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(85): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(90): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(95): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(100): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(105): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(110): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(115): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(120): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(125): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size
packf77.C(130): warning C4312: 'type cast': conversion from 'long' to 'Unpacker *' of greater size

History

#1 Updated by Sam White 4 months ago

  • Description updated (diff)

#2 Updated by Sam White 4 months ago

  • Description updated (diff)

#3 Updated by Sam White 4 months ago

  • Description updated (diff)

I got rid of most of these here: https://charm.cs.illinois.edu/gerrit/#/c/charm/+/3955/

The remaining ones are:

machine-common-core.c: In function 'CmiAbort':
machine-common-core.c:1692:1: warning: 'noreturn' function does return

machine.c: In function 'LrtsAbort':
machine.c:562:1: warning: 'noreturn' function does return
msgalloc.C(123): warning C4291: 'void *CMessage_CkMarshallMsg::operator new(std::size_t,int,const int,const GroupDepNum)':
no matching operator delete found; memory will not be freed if initialization throws an exception
machine-cma.c: In function 'readShmCma':
machine-cma.c:53:15: warning: implicit declaration of function 'process_vm_readv' [-Wimplicit-function-declaration]
   int nread = process_vm_readv(remote_pid, local, numOps, remote, numOps, 0);

machine-cma.c: In function 'writeShmCma':
machine-cma.c:71:15: warning: implicit declaration of function 'process_vm_writev' [-Wimplicit-function-declaration]
   int nread = process_vm_writev(remote_pid, local, numOps, remote, numOps, 0);
../bin/charmc -optimize -production -I. -c -o convcore.o convcore.c convcore.c(3187):
warning #266: function "LrtsRdmaFree" declared implicitly LrtsRdmaFree(BLKSTART(parentBlk)); 
machine-smp.c(153): warning C4311: 'type cast': pointer truncation from 'LPVOID' to 'int'
machine-smp.c(233): warning C4312: 'type cast': conversion from 'int' to 'LPVOID' of greater size

#4 Updated by Sam White 4 months ago

I think the noreturn warnings can be solved by adding "while(1);" to the end of those functions: https://stackoverflow.com/questions/15964219/noreturn-function-does-return

The 'process_vm_readv' warnings can I think be solved by #define _GNU_SOURCE: https://stackoverflow.com/questions/23477817/implicit-declaration-of-process-vm-readv-but-i-am-including-sys-uio-h
Actually it looks like we made that conditional to avoid some other compiler warnings here: https://charm.cs.illinois.edu/gerrit/#/c/charm/+/3625/
So I'm not sure what to do about that.

The "LrtsRdmaFree" warning can be solved by including the proper header that defines that routine.

#5 Updated by Evan Ramos 4 months ago

Sam White wrote:

I think the noreturn warnings can be solved by adding "while(1);" to the end of those functions: https://stackoverflow.com/questions/15964219/noreturn-function-does-return

Here are some header definitions adapted from a personal project of mine that we could add: (edited)

#ifndef __has_builtin
# define __has_builtin(x) 0  // Compatibility with non-clang compilers.
#endif

#if defined __GNUC__ || __has_builtin(__builtin_unreachable)
// Technically GCC 4.5 is the minimum for this feature, but we require C++11.
# define CMI_UNREACHABLE_SECTION(...) __builtin_unreachable()
#elif _MSC_VER
# define CMI_UNREACHABLE_SECTION(...) __assume(0)
#else
# define CMI_UNREACHABLE_SECTION(...) __VA_ARGS__
#endif

Then we could put `CMI_UNREACHABLE_SECTION(while(1));` at the bottom of these functions so that GCC, clang, and MSVC are explicitly informed that the position in the code is never reached.

The 'process_vm_readv' warnings can I think be solved by #define _GNU_SOURCE: https://stackoverflow.com/questions/23477817/implicit-declaration-of-process-vm-readv-but-i-am-including-sys-uio-h
Actually it looks like we made that conditional to avoid some other compiler warnings here: https://charm.cs.illinois.edu/gerrit/#/c/charm/+/3625/
So I'm not sure what to do about that.

The if condition is only to avoid warnings that would happen if we define _GNU_SOURCE when it is already defined. Either way, it will be defined after that block is preprocessed.

#6 Updated by Sam White 4 months ago

The if condition is only to avoid warnings that would happen if we define _GNU_SOURCE when it is already defined. Either way, it will be defined after that block is preprocessed.

Yeah, I'm just not sure why we're seeing the implicit declaration warnings when we're including the proper header and defining _GNU_SOURCE.

The CMI_UNREACHABLE_SECTION stuff looks good to me. We don't support GCC 4.5 anymore so I think we don't need the check for that.

#7 Updated by Sam White 4 months ago

I've updated the patch on gerrit. These are the only warnings left now from what I originally posted above:

msgalloc.C(123): warning C4291: 'void *CMessage_CkMarshallMsg::operator new(std::size_t,int,const int,const GroupDepNum)':
no matching operator delete found; memory will not be freed if initialization throws an exception

It looks like this can be fixed by also generating placement delete operators from charmxi: https://msdn.microsoft.com/en-us/library/cxdxz3x6.aspx

machine-cma.c: In function 'readShmCma':
machine-cma.c:53:15: warning: implicit declaration of function 'process_vm_readv' [-Wimplicit-function-declaration]
   int nread = process_vm_readv(remote_pid, local, numOps, remote, numOps, 0);

machine-cma.c: In function 'writeShmCma':
machine-cma.c:71:15: warning: implicit declaration of function 'process_vm_writev' [-Wimplicit-function-declaration]
   int nread = process_vm_writev(remote_pid, local, numOps, remote, numOps, 0);

I'm not sure why this warning appears despite the "#define _GNU_SOURCE".
../bin/charmc -optimize -production -I. -c -o convcore.o convcore.c convcore.c(3187):
warning #266: function "LrtsRdmaFree" declared implicitly LrtsRdmaFree(BLKSTART(parentBlk)); 

LrtsRdmaFree() is defined in GNI's machine.c but is called from Converse. I'm not sure where the declaration should go to fix this.

Nitin, can you take over these remaining warnings? They are coming from the Group Dependence, CMA, and zero copy API patches.

#8 Updated by Sam White 4 months ago

  • Assignee set to Nitin Bhat
  • % Done changed from 0 to 90

#9 Updated by Sam White 4 months ago

  • Status changed from New to In Progress

#10 Updated by Sam White 3 months ago

  • Target version set to 6.9.0

These should be fixed for 6.9.0

#11 Updated by Nitin Bhat 3 months ago

Sure, I'll take a look at these.

#12 Updated by Nitin Bhat 3 months ago

Fixes:
LrtsRdmaFree Warning: https://charm.cs.illinois.edu/gerrit/#/c/charm/+/4008/
MarshallMsg Warning: https://charm.cs.illinois.edu/gerrit/#/c/charm/+/4007/

The warnings inside writeShmCma and readShmCma are only showing up on CrayXC because there are no header files with the function declarations. The original linux header file "sys/uio.h" doesn't have the declarations (unlike other linux platforms). There's a hceader file "bits/uio.h", which has the declarations, however they are guarded by #if __USE_GNU, which isn't true when I use PrgEnv-Intel. I've reported this issue to sysadmins.

On Crayxc, in addition to the CMA implicit declaration warnings, I noticed the following errors on building LIBS:


csr.c(1677): warning #3180: unrecognized OpenMP #pragma
    #pragma omp parallel for if (ptr[n] > OMPMINOPS) schedule(static)
            ^
error.c(185): warning #266: function "strerror_r" declared implicitly
    strerror_r(errnum, buf, 1024);
    ^

#13 Updated by Sam White 3 months ago

For the OpenMP warnings we could potentially wrap all of the #pragma omp statements in conditional guards like CMK_HAS_OPENMP or something, but I'm not sure what csr.c is.

For the strerror_r one I think we just need to add a "#include <string.h>" somewhere.

#14 Updated by Sam White 3 months ago

This cleans up the remaining warnings seen when building "LIBS" on netlrts-linux-x86_64. I think we could now add -Werror=pedantic to Jenkins commit-triggered builds if we want: https://charm.cs.illinois.edu/gerrit/#/c/charm/+/4009/

#15 Updated by Sam White 3 months ago

  • Status changed from In Progress to Merged

Marking this merged for now

Also available in: Atom PDF