Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'stringop-overflow' compiler warning when compiling CGAL/Polygon_mesh_processing/repair_polygon_soup.h with mingw64/bin/c++.exe #8697

Open
Zamsarul-hub opened this issue Jan 17, 2025 · 1 comment
Labels
Not a bug Pkg::PMP Warnings For an issue about warnings, or a pull-request that fixes warnings
Milestone

Comments

@Zamsarul-hub
Copy link

Zamsarul-hub commented Jan 17, 2025

Please use the following template to help us solving your issue.

Issue Details

stringop-overflow compilation warning when compiling repair_polygon_soup.h with mingw64/bin/c++.exe.

FAILED: src/WAMlib/CMakeFiles/WAMlib.dir/mesh/mesh_extra.cpp.obj 
ccache C:\ProgramData\scoop\apps\msys2\2024-07-27\mingw64\bin\c++.exe -DBOOST_CONTEXT_EXPORT="" -DBOOST_CONTEXT_NO_LIB="" -DBOOST_CONTEXT_STATIC_LINK="" -DBOOST_FIBER_NO_LIB -DBOOST_FIBER_STATIC_LINK -DCGAL_DISABLE_ROUNDING_MATH_CHECK=\"ON\" -DCGAL_EIGEN3_ENABLED -DCGAL_USE_GMPXX=1 -DENABLE_DATE_LIMIT -DENABLE_DEBUG_FEATURES -DENABLE_LICENSE_FEATURE -DEXPIRY_DATE=\"2025-03-01\" -DMINGW_HAS_SECURE_API=1 -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_OPENGL_LIB -DQT_QMLBUILTINS_LIB -DQT_QMLINTEGRATION_LIB -DQT_QMLMODELS_LIB -DQT_QML_DEBUG -DQT_QML_LIB -DQT_QUICK3DRUNTIMERENDER_LIB -DQT_QUICK3DUTILS_LIB -DQT_QUICK3D_LIB -DQT_QUICKWIDGETS_LIB -DQT_QUICK_LIB -DQT_SHADERTOOLS_LIB -DQT_WIDGETS_LIB -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_GNU_SOURCE -D_UNICODE -D_WIN64 -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/src/WAMlib/WAMlib_autogen/include -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/src/WAMlib -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/geom/script -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/.. -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/../core -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/../core/include -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/common -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/primitives -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/geom -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/geometry -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/system -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/mesh -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/datastructure -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/transformer -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/guideliner -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/slicer -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/pathplanner -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/bead_processor -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/io -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/params -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/positioner -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/crates/target/cxxbridge -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/cargo/build/x86_64-pc-windows-gnu/cxxbridge -IC:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/include -isystem C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/vcpkg_installed/x64-mingw-static/include/eigen3 -isystem C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/vcpkg_installed/x64-mingw-static/include -isystem C:/Qt/6.7.2/mingw_64/include/QtCore -isystem C:/Qt/6.7.2/mingw_64/include -isystem C:/Qt/6.7.2/mingw_64/mkspecs/win32-g++ -isystem C:/Qt/6.7.2/mingw_64/include/QtWidgets -isystem C:/Qt/6.7.2/mingw_64/include/QtGui -isystem C:/Qt/6.7.2/mingw_64/include/QtQuick -isystem C:/Qt/6.7.2/mingw_64/include/QtQml -isystem C:/Qt/6.7.2/mingw_64/include/QtQmlIntegration -isystem C:/Qt/6.7.2/mingw_64/include/QtQmlBuiltins -isystem C:/Qt/6.7.2/mingw_64/include/QtNetwork -isystem C:/Qt/6.7.2/mingw_64/include/QtQmlModels -isystem C:/Qt/6.7.2/mingw_64/include/QtOpenGL -isystem C:/Qt/6.7.2/mingw_64/include/QtQuickWidgets -isystem C:/Qt/6.7.2/mingw_64/include/QtQuick3D -isystem C:/Qt/6.7.2/mingw_64/include/QtQuick3DRuntimeRender -isystem C:/Qt/6.7.2/mingw_64/include/QtQuick3DUtils -isystem C:/Qt/6.7.2/mingw_64/include/QtShaderTools -isystem C:/Qt/6.7.2/mingw_64/include/QtConcurrent -g -std=gnu++20 -g3 -ggdb3 -O3 -Wa,-mbig-obj -fvisibility=hidden -fvisibility-inlines-hidden -flarge-source-files -frounding-math -Werror -MD -MT src/WAMlib/CMakeFiles/WAMlib.dir/mesh/mesh_extra.cpp.obj -MF src\WAMlib\CMakeFiles\WAMlib.dir\mesh\mesh_extra.cpp.obj.d -o src/WAMlib/CMakeFiles/WAMlib.dir/mesh/mesh_extra.cpp.obj -c C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/mesh/mesh_extra.cpp
In file included from C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/algorithm:60,
                 from C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/vcpkg_installed/x64-mingw-static/include/CGAL/config.h:260,
                 from C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/vcpkg_installed/x64-mingw-static/include/CGAL/license/AABB_tree.h:17,
                 from C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/vcpkg_installed/x64-mingw-static/include/CGAL/AABB_face_graph_triangle_primitive.h:17,
                 from C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/primitives/cgal_adapt.h:3,
                 from C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/mesh/mesh_extra.h:3,
                 from C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/src/WAMlib/mesh/mesh_extra.cpp:1:
In static member function 'static constexpr _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = const long long unsigned int; _Up = long long unsigned int; bool _IsMove = false]',
    inlined from 'constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = const long long unsigned int*; _OI = long long unsigned int*]' at C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_algobase.h:521:30,
    inlined from 'constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = const long long unsigned int*; _OI = long long unsigned int*]' at C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_algobase.h:548:42,
    inlined from 'constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator<const long long unsigned int*, vector<long long unsigned int> >; _OI = long long unsigned int*]' at C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_algobase.h:555:31,
    inlined from 'constexpr _OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const long long unsigned int*, vector<long long unsigned int> >; _OI = long long unsigned int*]' at C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_algobase.h:651:7,
    inlined from 'static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const long long unsigned int*, std::vector<long long unsigned int> >; _ForwardIterator = long long unsigned int*]' at C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_uninitialized.h:147:27,
    inlined from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const long long unsigned int*, vector<long long unsigned int> >; _ForwardIterator = long long unsigned int*]' at C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_uninitialized.h:185:15,
    inlined from 'constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const long long unsigned int*, vector<long long unsigned int> >; _ForwardIterator = long long unsigned int*; _Tp = long long unsigned int]' at C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_uninitialized.h:373:37,
    inlined from 'constexpr std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = long long unsigned int; _Alloc = std::allocator<long long unsigned int>]' at C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_vector.h:606:31,
    inlined from 'Polygon CGAL::Polygon_mesh_processing::internal::construct_canonical_polygon(const PointRange&, const Polygon&, bool&, const Traits&) [with Traits = CGAL::Epick; PointRange = std::vector<CGAL::Point_3<CGAL::Epick> >; Polygon = std::vector<long long unsigned int>]' at C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/vcpkg_installed/x64-mingw-static/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h:696:12,
    inlined from 'DuplicateOutputIterator CGAL::Polygon_mesh_processing::internal::collect_duplicate_polygons(const PointRange&, const PolygonRange&, DuplicateOutputIterator, const Traits&, bool) [with PointRange = std::vector<CGAL::Point_3<CGAL::Epick> >; PolygonRange = std::vector<std::vector<long long unsigned int> >; DuplicateOutputIterator = std::back_insert_iterator<std::deque<std::vector<long long unsigned int>, std::allocator<std::vector<long long unsigned int> > > >; Traits = CGAL::Epick]' at C:/GitLab-Runner/builds/-P3pixj38/0/aml3d/monorepo/wamsoft/build/Debug/vcpkg_installed/x64-mingw-static/include/CGAL/Polygon_mesh_processing/repair_polygon_soup.h:867:44:
C:/ProgramData/scoop/apps/msys2/2024-07-27/mingw64/include/c++/14.1.0/bits/stl_algobase.h:452:30: error: 'void* __builtin_memmove(void*, const void*, long long unsigned int)' writing between 9 and 9223372036854775807 bytes into a region of size 8 overflows the destination [-Werror=stringop-overflow=]
  452 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Source Code

 85 CGAL_Mesh repair_polygon_soup(const CGAL_Mesh& mesh) {
 86     std::vector<K::Point_3> points;
 87     std::vector<std::vector<std::size_t>> polygons;
 88     CGAL_PMP::polygon_mesh_to_polygon_soup(mesh, points, polygons);
 89     
 90     CGAL_PMP::repair_polygon_soup(points, polygons);
 91     CGAL_PMP::orient_polygon_soup(points, polygons);
 92     
 93     CGAL_Mesh repaired_mesh;
 94     CGAL_PMP::polygon_soup_to_polygon_mesh(points, polygons, repaired_mesh);
 95     return repaired_mesh;  
 96 } 

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): Windows, 64 bits
  • Compiler: mingw64\bin\c++.exe
  • Release or debug mode: debug
  • Specific flags used (if any):
  • CGAL version: 6.0 (from vcpkg)
  • Boost version:
  • Other libraries versions if used (Eigen, TBB, etc.):
@Zamsarul-hub Zamsarul-hub changed the title mingw64/bin/c++.exe gives 'stringop-overflow' warning when compiling CGAL/Polygon_mesh_processing/repair_polygon_soup.h 'stringop-overflow' compiler warning when compiling CGAL/Polygon_mesh_processing/repair_polygon_soup.h with mingw64/bin/c++.exe Jan 17, 2025
@lrineau
Copy link
Member

lrineau commented Mar 14, 2025

Hi @Zamsarul-hub,

The warning is in an STL code about the copy of a std::vector<_Tp>, where _Tp is the type long long unsigned int (that is std::size_t). The size of that _Tp type is 8 bytes.

In static member function 'static constexpr _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = const long long unsigned int; _Up = long long unsigned int; bool _IsMove = false]',

The warning is in that function in the file bits/stl_algobase.h:

  template<bool _IsMove>
    struct __copy_move<_IsMove, true, random_access_iterator_tag>
    {
      template<typename _Tp, typename _Up>
        _GLIBCXX20_CONSTEXPR
        static _Up*
        __copy_m(_Tp* __first, _Tp* __last, _Up* __result)
        {
          const ptrdiff_t _Num = __last - __first;
          if (__builtin_expect(_Num > 1, true))
            __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);    // LINE 452 OF THE FILE
          else if (_Num == 1)
            std::__copy_move<_IsMove, false, random_access_iterator_tag>::
              __assign_one(__result, __first);
          return __result + _Num;
        }
    };

That looks like a compiler bug. The warning is:

.../bits/stl_algobase.h:452:30: error: 'void* __builtin_memmove(void*, const void*, long long unsigned int)' writing between 9 and 9223372036854775807 bytes into a region of size 8 overflows the destination [-Werror=stringop-overflow=]
  452 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if the compiler assumes that the destination region is of size 8, then sizeof(_Tp) * _Num must be 8. But the code line 452 is called only if _Num > 1 (the condition of the previous line).

I do not know what the CGAL code can change to remove that warning. It is unfortunately a false positive.

I think this issue should be closed as "not a bug" (meaning: not a bug in CGAL). What do you think, @Zamsarul-hub?

@lrineau lrineau added this to the 6.0.2 milestone Mar 14, 2025
@lrineau lrineau added the Warnings For an issue about warnings, or a pull-request that fixes warnings label Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a bug Pkg::PMP Warnings For an issue about warnings, or a pull-request that fixes warnings
Projects
None yet
Development

No branches or pull requests

3 participants