gcc12 support request / array bound warning
Closed this issue · 5 comments
Can you please add support for gcc12? I'm seeing some errors in my build w/gcc12.
../src/immer/detail/hamts/node.hpp:216:38: error: array subscript ‘immer::detail::hamts::node<std::pair<long unsigned int, long unsigned int>, immer::map<long unsigned int, long unsigned int>::hash_key, immer::map<long unsigned int, long unsigned int>::equal_key, immer::memory_policy<immer::free_list_heap_policy<immer::cpp_heap>, immer::refcount_policy, immer::spinlock_policy>, 5>[0]’ is partly outside array bounds of ‘unsigned char [24]’ [-Werror=array-bounds]
216 | p->impl.d.data.inner.nodemap = 0;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
I have not yet figured out how to build your tests otherwise I'd provide a more detailed repro. Apologies.
Immer already works properly with GCC 12. It would require further investigation, but I do not think that the warning is pointing to any bug in the immer
code, but instead, GCC is simply getting confused about immer's low level tricks. I would recommend to add third party libraries to the search path of GCC with -isystem
instead of -I
, in order to avoid warnings from third party code.
Thanks for the quick reply. I am a little concerned by your response. Are you suggesting GCC12 displays evidence of a GCC12 bug when compiling immer?
No. The error that you are seeing is not actually an error, but a warning. (It is causing the build to fail because you are also using the -Werror
flag to treat all warnings as errors). What I am suggesting is that this warning, in this case, is not showing a bug in the Immer code, and therefore can be ignored.
I understand. You are suggesting GCC12's warning is erroneous, which in my mind is a kind of bug.
I'm not sure. The warning can be useful in some other context. A warning is telling you: your code could be wrong because it's doing something dangerous! In this case the code is correct in spite of doing dangerous stuff. I am not sure the warning is wrong.