-
Notifications
You must be signed in to change notification settings - Fork 41
GCC 7 Compiler Bug
There seems to be a significant issue on my system with compiling Polylidar with gcc-7 on a specific branch (cppisolate). I have isolated the issue to being with the robinhood hasmhap: The hashmap does bizarre things and does not act as expected. Actions such as checking if a key is in the map and deleting a key do not seem to work. Errors can be reproduced with debugging at (cppisolate) branch. The weird part is that one branch (master) works fine but (cppisolate) branch does not and the changes had NOTHING to do with the robinhood hashing.
These issues go completely away when compiling with GCC5, GCC6, GCC8, GCC9, Clang6 on LinuxX86_64. Also on windows MSVC compiler has no issues. This was a very annoying bug to diagnose but I have no idea how to fix it. I really feel like this is some type of weird compiler or undefined behavior bug.
This was "resolved" by ensuring that only O1 optimizations occur on the function createTriHashX. We use the GNU specific attribute: https://github.com/JeremyBYU/polylidarv2/blob/7e3a6a50906df90419df7fd33ccae78e8ec1f8f5/polylidar/polylidar.hpp#L56
This was further fixed by replacing the offending code with a different data structure (hash map to vector). It was an optimization that lead to a speedup as well.