Thanks to @MarekR I figured the root cause now. It appears that the two compare_swap_strong calls in push function have incorrectly placed parenthesis. More specifically a right parenthesis has been placed after the second parameter where in fact should be at the end of the statement. This causes the two memory order parameters to become part of the while loop condition thanks to comma operator, and they end up interfering with condition evaluation. Therefore the do while loop would terminate even if compare_swap_strong returns false. Moving the right parenthesis to the end of the line solves the problem.