This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Disable -Wstringop-overflow
ClosedPublic

Authored by Hahnfeld on Jul 26 2018, 11:46 PM.

Details

Summary

GCC 8 produces false-positives with this:

In file included from <openmp>/src/runtime/src/kmp_os.h:950,
                 from <openmp>/src/runtime/src/kmp.h:78,
                 from <openmp>/src/runtime/src/kmp_environment.cpp:54:
<openmp>/src/runtime/src/kmp_environment.cpp: In function ‘char* __kmp_env_get(const char*)’:
<openmp>/src/runtime/src/kmp_safe_c_api.h:52:50: warning: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
 #define KMP_STRNCPY_S(dst, bsz, src, cnt) strncpy(dst, src, cnt)
                                           ~~~~~~~^~~~~~~~~~~~~~~
<openmp>/src/runtime/src/kmp_environment.cpp:97:5: note: in expansion of macro ‘KMP_STRNCPY_S’
     KMP_STRNCPY_S(result, len, value, len);
     ^~~~~~~~~~~~~
<openmp>/src/runtime/src/kmp_environment.cpp:92:28: note: length computed here
     size_t len = KMP_STRLEN(value) + 1;

This is stupid because result is allocated with KMP_INTERNAL_MALLOC(len),
so the arguments are correct.

Diff Detail

Repository
rOMP OpenMP

Event Timeline

Hahnfeld created this revision.Jul 26 2018, 11:46 PM
This revision is now accepted and ready to land.Jul 30 2018, 10:53 AM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.

Can you turn off -Woverloaded-virtual for GCC? There are warnings during the build, which are not relevant (according to the person who commited the change which caused this warning with GCC, I asked him to check it some time ago)

Can you turn off -Woverloaded-virtual for GCC? There are warnings during the build, which are not relevant (according to the person who commited the change which caused this warning with GCC, I asked him to check it some time ago)

I'm not seeing any of these for libomp which this change is for. AFAICS there are no virtual methods in the OpenMP runtime, are you maybe talking about LLVM?

Can you turn off -Woverloaded-virtual for GCC? There are warnings during the build, which are not relevant (according to the person who commited the change which caused this warning with GCC, I asked him to check it some time ago)

I'm not seeing any of these for libomp which this change is for. AFAICS there are no virtual methods in the OpenMP runtime, are you maybe talking about LLVM?

Yes, LLVM

Can you turn off -Woverloaded-virtual for GCC? There are warnings during the build, which are not relevant (according to the person who commited the change which caused this warning with GCC, I asked him to check it some time ago)

I'm not seeing any of these for libomp which this change is for. AFAICS there are no virtual methods in the OpenMP runtime, are you maybe talking about LLVM?

Yes, LLVM

In that case you'll submit a change to the LLVM build system, this patch is only about the OpenMP runtime.