Open JPeterMugaas opened 10 months ago
I've done a lot of recent updates for CodeQL warnings, so please retry with the latest version (I.e. the main branch) to see if this one is fixed.
I tried the main branch but still got the warnings.
If I understand correctly here, it's complaining about the difference between a uint64_t
and an int64_t
.
I don't know how it got there. m_dwVertNumber
is size_t
. memset
takes a size_t
per the standard. I thought size_t
was always unsigned and ptrdiff_t
was always signed. Per the standard, I thought sizeof
returns size_t, but I wonder if GNU is assuming it's int?
What's strange is the same pattern is used elsewhere and it doesn't complain elsewhere...
I just tried building with MinGW-w64 13.2.0 r4 and I'm not seeing these warnings.
OK, so they only show up in release builds. Not debug builds.
lto-wrapper.exe: warning: using serial compilation of 9 LTRANS jobs
lto-wrapper.exe: note: see the '-flto' option documentation for more information
In member function 'CalculateDijkstraPathToVertex',
inlined from 'CaculateDistanceToExtremeVertex' at D:/Microsoft/UVAtlas/UVAtlas/isochart/meshpartitionchart.cpp:1840:9,
inlined from 'CheckCylinderLonghornShape' at D:/Microsoft/UVAtlas/UVAtlas/isochart/meshpartitionchart.cpp:1740:5,
inlined from 'ProcessSpecialShape' at D:/Microsoft/UVAtlas/UVAtlas/isochart/meshpartitionchart.cpp:1640:5,
inlined from 'Partition' at D:/Microsoft/UVAtlas/UVAtlas/isochart/isochartmesh.cpp:797:29,
inlined from '_ZN8Isochart15CIsochartEngine36ParameterizeChartsInHeapParallelizedEby._omp_fn.0' at D:/Microsoft/UVAtlas/UVAtlas/isochart/isochartengine.cpp:322:47:
D:/Microsoft/UVAtlas/UVAtlas/isochart/isochartmesh.cpp:3350:11: warning: '__builtin_memset' specified size between 9223372036854775809 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
3350 | memset(pbVertProcessed, 0, sizeof(bool) * m_dwVertNumber);
| ^
In member function 'CalculateGeodesicDistanceToVertexKS98',
inlined from 'CalculateGeodesicDistanceToVertex' at D:/Microsoft/UVAtlas/UVAtlas/isochart/meshapplyisomap.cpp:475:46,
inlined from 'CalculateGeodesicDistance' at D:/Microsoft/UVAtlas/UVAtlas/isochart/meshapplyisomap.cpp:291:13:
D:/Microsoft/UVAtlas/UVAtlas/isochart/meshapplyisomap.cpp:565:11: warning: '__builtin_memset' specified size between 9223372036854775809 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
565 | memset(pbVertProcessed.get(), 0, sizeof(bool) * m_dwVertNumber);
| ^
D:/Microsoft/UVAtlas/UVAtlas/isochart/meshpartitionchart.cpp: In member function 'GenerateAllSubCharts':
D:/Microsoft/UVAtlas/UVAtlas/isochart/meshpartitionchart.cpp:32:119: warning: argument 1 value '18446744073709551615' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
32 | std::unique_ptr<std::vector<uint32_t>[]> chartFaceList(new (std::nothrow) std::vector<uint32_t>[dwMaxSubchartCount]);
|
^
C:/mingw64/include/c++/13.2.0/new:142:26: note: in a call to allocation function 'operator new []' declared here
142 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
According to some research here, GCC is actually complaining if it exceeds PTRDIFF_MAX - 1
which is the signed int vs. size_t which is an unsigned int.
It looks like a number of people feel this warning is spurious. Still, I'll see if I can make it happy. What I really don't understand is why it only complains in SOME of the cases which are all basically identical.
There is a page in the GCC manual about warning options at: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html .
I have to be honest in saying that I do feel that this is a spurious warning and from a practical point of view, it might be best to use a "hacky" but somewhat elegant fix for it that will work. The for loop I tied does work and I think SecureZeroMemory will also work if it's ifdefed out for Linux.
I compiled UVAtlas with GNU 13.2.0 and I got some Wstringop-overflow warnings:
From the GCC manual: