GCC 8.2 Warning in Testing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GCC 8.2 Warning in Testing

Bill Lorensen
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)


--
Unpaid intern in BillsParadise at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: GCC 8.2 Warning in Testing

Bill Lorensen
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


On Tue, Feb 5, 2019 at 7:15 AM Bill Lorensen <[hidden email]> wrote:

>
> 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)
>
>
> --
> Unpaid intern in BillsParadise at noware dot com



--
Unpaid intern in BillsParadise at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers