std::numeric_limits used without including <limits>
dwightguth opened this issue · comments
When I build immer with the most recent distro of Arch Linux, I get a compiler error:
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:664:31: error: no member named 'numeric_limits' in namespace 'std'
assert(r.size < (std::numeric_limits<size_t>::max() - size));
~~~~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:664:46: error: unexpected type name 'size_t': expected expression
assert(r.size < (std::numeric_limits<size_t>::max() - size));
^
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:664:55: error: no member named 'max' in the global namespace
assert(r.size < (std::numeric_limits<size_t>::max() - size));
~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:744:31: error: no member named 'numeric_limits' in namespace 'std'
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
~~~~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:744:46: error: unexpected type name 'size_t': expected expression
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
^
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:744:55: error: no member named 'max' in the global namespace
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:867:31: error: no member named 'numeric_limits' in namespace 'std'
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
~~~~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:867:46: error: unexpected type name 'size_t': expected expression
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
^
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:867:55: error: no member named 'max' in the global namespace
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:1010:31: error: no member named 'numeric_limits' in namespace 'std'
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
~~~~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:1010:46: error: unexpected type name 'size_t': expected expression
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
^
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:1010:55: error: no member named 'max' in the global namespace
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:1143:31: error: no member named 'numeric_limits' in namespace 'std'
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
~~~~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
In file included from /root/llvm-backend/runtime/arithmetic/int.cpp:6:
In file included from /root/llvm-backend/include/runtime/header.h:15:
In file included from /root/llvm-backend/build/include/immer/flex_vector.hpp:11:
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:1143:46: error: unexpected type name 'size_t': expected expression
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
^
/root/llvm-backend/build/include/immer/detail/rbts/rrbtree.hpp:1143:55: error: no member named 'max' in the global namespace
assert(r.size < (std::numeric_limits<size_t>::max() - l.size));
~~^
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
15 errors generated.
Casual search on the internet tells me that std::numeric_limits is defined in the <limits>
header. If I include this header before including flex_vector.hpp
, everything compiles correctly.
I am assuming what is happening here is that these fields used to be implicitly included by another header that was already being included, but that more recent versions of the C++ standard library are more precise about including only exactly what the user asks for, as a result of which, you get this error.
The solution is probably to add a #include <limits>
to rrbtree.hpp
.
@dwightguth , @maierlars submitted this patch and it already merged.
8ecf460