The bug you describe most probably is PR 21963 (and there is a patch for
this PR submitted).
Actually, I found out after my email that the exact case I found is
PR22212, but 21963 does look like the same symptom. What's the status
of this patch?