# GCC 8.2 Warning in Testing

**URL:** <https://discourse.vtk.org/t/gcc-8-2-warning-in-testing/222>\
**Category:** Development\
**Created:** [February 5, 2019, 7:05pm UTC](https://discourse.vtk.org/t/gcc-8-2-warning-in-testing/222 "2019-02-05T19:05:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)\
**Post date:** [February 5, 2019, 7:05pm UTC](https://discourse.vtk.org/t/gcc-8-2-warning-in-testing/222/1 "2019-02-05T19:05:00Z")

</div>

Folks,

The following warnings are present with the gcc 8.2 compiler. They  
occur in the test cxx files.

Building CXX object  
Common/Core/Testing/Cxx/CMakeFiles/vtkCommonCoreCxxTests.dir/vtkCommonCoreCxxTests.cxx.o  
In function â€˜char\* lowercase(const char\*)â€™,  
inlined from â€˜int main(int, char\*\*)â€™ at  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:380:20:  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:332:10:  
warning: â€˜char\* strncpy(char\*, const char\*, size\_t)â€™ specified  
bound depends on the length of the source argument  
[-Wstringop-overflow=]  
strncpy(new\_string, string, stringSize);  
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:  
In function â€˜int main(int, char\*\*)â€™:  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:326:38:  
note: length computed here  
stringSize = CM\_CAST(size\_t, strlen(string) + 1);  
~~^~~~  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:73:47:  
note: in definition of macro â€˜CM\_CASTâ€™  
#define CM\_CAST(TYPE, EXPR) static\_cast\<TYPE\>(EXPR)  
^~~~  
In function â€˜char\* lowercase(const char\*)â€™,  
inlined from â€˜int main(int, char\*\*)â€™ at  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:383:26:  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:332:10:  
warning: â€˜char\* strncpy(char\*, const char\*, size\_t)â€™ specified  
bound depends on the length of the source argument  
[-Wstringop-overflow=]  
strncpy(new\_string, string, stringSize);  
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:  
In function â€˜int main(int, char\*\*)â€™:  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:326:38:  
note: length computed here  
stringSize = CM\_CAST(size\_t, strlen(string) + 1);  
~~^~~~  
/home/lorensen/ProjectsGIT/VTKNewModules-linux/Common/Core/Testing/Cxx/vtkCommonCoreCxxTests.cxx:73:47:  
note: in definition of macro â€˜CM\_CASTâ€™  
#define CM\_CAST(TYPE, EXPR) static\_cast\<TYPE\>(EXPR)

---

<div class="post-metadata">

**Author:** ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)\
**Post date:** [February 5, 2019, 7:06pm UTC](https://discourse.vtk.org/t/gcc-8-2-warning-in-testing/222/2 "2019-02-05T19:06:21Z")

</div>

This warning was fixed in cmake 3.11.3.

Two solutions:

1. Require 3.11.3 or higher.
2. Users can add -Wstringop-overflow=0 to CMAKE\_CXX\_FLAGS
