BinTree AVL bug with specific GCC compiler
Closed this issue · 1 comments
Hey there!
I have experienced a bug using CppTrader, on Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-1022-aws aarch64). It's severe but very easy to fix. Most compilers interprets 'char' as 'signed char' but gcc in this ubuntu for some reason interprets it as 'unsigned char' by default.
Therefore, function std::pair BinTreeAVL::insert(const const_iterator&, T&) at bintree_avl.inl:266 under some circumstances can stuck in endless loop because it tries to compare 'balance' variable with '-1' and always fails.
Fix is simple, replace line at bintree_avl.h:122 with 'signed char balance;'.
I did this in my local copy and it fixed the issue.
I also suggest to check other algos for this bug if there are similar structures.
Fixed! Thanks for reporting!