I have found what seems to me an issue with overloading the use of last_post_id (and first_post_id) with two different meanings.
In fact, last_post_id means, sometimes, highest post id, and other times, post id of the latest post time. However, it is always calculated as highest post id, assuming that the highest post id corresponds to the id of the latest post. This last assumption is FALSE under certain circumstances, and hence, the output is not what is expected. These are rare cases though, but "semantically", the two concepts are incorrectly intermixed in my view.
Full description and example: https://area51.phpbb.com/phpBB/viewtopic.php?f=126&t=50961