martinus / robin-hood-hashing

Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
https://gitter.im/martinus/robin-hood-hashing
MIT License
1.5k stars 143 forks source link

robin_hood.h:2012:13: error: attempt to free a non-heap object 'fm' [-Werror=free-nonheap-object] #50

Closed zenfey closed 4 years ago

zenfey commented 4 years ago

https://github.com/martinus/robin-hood-hashing/blob/813dadddc58417385bf7dff9fb2e1f5939c23598/src/include/robin_hood.h#L2012

COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-7.3.1-20180303/obj-x86_64-redhat-linux/isl-install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)

zenfey commented 4 years ago
[  1%] Building CXX object CMakeFiles/rh.dir/src/test/unit/unit_calcsize.cpp.o
In file included from /robin-hood-hashing/src/test/unit/unit_calcsize.cpp:1:0:
In member function ‘void robin_hood::detail::unordered_map<IsFlatMap, MaxLoadFactor100, Key, T, Hash, KeyEqual>::destroy() [with bool IsFlatMap = true; long unsigned int MaxLoadFactor100 = 80; Key = long unsigned int; T = long unsigned int; Hash = robin_hood::hash<long unsigned int>; KeyEqual = std::equal_to<long unsigned int>]’,
    inlined from ‘robin_hood::detail::unordered_map<IsFlatMap, MaxLoadFactor100, Key, T, Hash, KeyEqual>::~unordered_map() [with bool IsFlatMap = true; long unsigned int MaxLoadFactor100 = 80; Key = long unsigned int; T = long unsigned int; Hash = robin_hood::hash<long unsigned int>; KeyEqual = std::equal_to<long unsigned int>]’ at /robin-hood-hashing/src/include/robin_hood.h:1506:16,
    inlined from ‘void _DOCTEST_ANON_FUNC_2()’ at /robin-hood-hashing/src/test/unit/unit_calcsize.cpp:6:56:
/robin-hood-hashing/src/include/robin_hood.h:2012:13: error: attempt to free a non-heap object ‘fm’ [-Werror=free-nonheap-object]
         free(mKeyVals);
         ~~~~^~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/rh.dir/build.make:479: CMakeFiles/rh.dir/src/test/unit/unit_calcsize.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/rh.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
martinus commented 4 years ago

Hi, thanks for reporting! I could reproduce this warning with g++-7 (it works with g++5, g++9.2, clang++6, clang++9...) and have modified the code so this error doesn't happen.

Please try the newest version 3.4.2.