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 142 forks source link

Weird compile error on Ubuntu 21.10 #133

Closed bhaller closed 2 years ago

bhaller commented 2 years ago

Hi! I've got a user on Ubuntu 21.10; I am not on that platform myself. The user reports:

I am trying to compile SLiM on two new machines running Ubuntu 21.10

I have tried to install using the installation script from session 2.2.1 from the manual and compiling from source following sessions 2.2.2

I have all make, cmake, qmake and Qt5 installed in both machines.

Both pathways end up in errors, around 90-91% of the process.

From the script I get the following:

[ 90%] Building CXX object CMakeFiles/SLiMgui.dir/SLiMgui_autogen/UXQW7GK73I/qrc_recipes.cpp.o make[1]: [CMakeFiles/Makefile2:169: CMakeFiles/slim.dir/all] Error 2 [ 90%] Linking CXX executable SLiMgui [ 90%] Built target SLiMgui make: [Makefile:149: all] Error 2 Build failed. Please see the output and make a post on the slim-discuss mailing list. The output from this build is stored in '/var/log/' as SLiM-CMakeOutput-2021-11-03T16:11:57-04:00.log. You may be asked to upload this file during a support request.

(I've attached the log file here).

From the source code, the error is the following:

[ 70%] Building CXX object CMakeFiles/eidos.dir/eidos/eidos_ast_node.cpp.o
In file included from /path/to/SLiM/eidos/eidos_class_Dictionary.h:31,
                 from /path/to/SLiM/eidos/eidos_value.h:46,
                 from /path/to/SLiM/eidos/eidos_ast_node.h:28,
                 from /path/to/SLiM/eidos/eidos_ast_node.cpp:21:
/path/to/SLiM/eidos/robin_hood.h: In member function ‘size_t robin_hood::detail::Table<IsFlat, MaxLoadFactor100, Key, T, Hash, KeyEqual>::calcMaxNumElementsAllowed(size_t) const’:
/path/to/SLiM/eidos/robin_hood.h:2021:52: error: ‘numeric_limits’ is not a member of ‘std’
 2021 |         if (ROBIN_HOOD_LIKELY(maxElements <= (std::numeric_limits<size_t>::max)() / 100)) {
      |                                                    ^~~~~~~~~~~~~~
/path/to/SLiM/eidos/robin_hood.h:179:59: note: in definition of macro ‘ROBIN_HOOD_LIKELY’
  179 | #    define ROBIN_HOOD_LIKELY(condition) __builtin_expect(condition, 1)
      |                                                           ^~~~~~~~~
/path/to/SLiM/eidos/robin_hood.h:2021:73: error: expected primary-expression before ‘>’ token
 2021 | ROBIN_HOOD_LIKELY(maxElements <= (std::numeric_limits<size_t>::max)() / 100)) {
      |                                                             ^

/path/to/SLiM/eidos/robin_hood.h:179:59: note: in definition of macro ‘ROBIN_HOOD_LIKELY’
  179 | #    define ROBIN_HOOD_LIKELY(condition) __builtin_expect(condition, 1)
      |                                                           ^~~~~~~~~
/path/to/SLiM/eidos/robin_hood.h:2021:76: error: ‘::max’ has not been declared; did you mean ‘std::max’?
 2021 | IN_HOOD_LIKELY(maxElements <= (std::numeric_limits<size_t>::max)() / 100)) {
      |                                                             ^~~

/path/to/SLiM/eidos/robin_hood.h:179:59: note: in definition of macro ‘ROBIN_HOOD_LIKELY’
  179 | #    define ROBIN_HOOD_LIKELY(condition) __builtin_expect(condition, 1)
      |                                                           ^~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /path/to/SLiM/eidos/eidos_globals.h:33,
                 from /path/to/SLiM/eidos/eidos_token.h:29,
                 from /path/to/SLiM/eidos/eidos_ast_node.h:27,
                 from /path/to/SLiM/eidos/eidos_ast_node.cpp:21:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: ‘std::max’ declared here
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
make[2]: *** [CMakeFiles/eidos.dir/build.make:82: CMakeFiles/eidos.dir/eidos/eidos_ast_node.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:140: CMakeFiles/eidos.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

These errors seem... strange. Take the first one, "error: ‘numeric_limits’ is not a member of ‘std’". Well, it certainly is. :-> Presumably this is a header problem. numeric_limits is defined in limits.h. My code includes a copy of robin_hood.h that is marked as version 3.9.0. That version does not include limits.h, but I added that include a while back because Fedora 34 needed it, so the include is there. So why would this error occur, then?

So, since I am not set up to test on this platform this issue might be a bit useless, but I guess it can be taken to represent two things. (1) The header ought to include limits.h since it uses numeric_limits, I guess. (2) There might be a weird problem on Ubuntu 21.10 even when limits.h is added. If somebody here has further insight into what is going on here, that would be great. :->

bhaller commented 2 years ago

Aha! The user appears to be using an older version of the sources that does not contain my addition of limits.h. So this issue is simple, then: limits.h should be added to robin_hood.h. And I see that it has been added since the version I incorporated; so there is no bug, then. So never mind. Closing.