If the following condition is remove, no failure occurs:
utxo.fee != utxo_pool.at(utxo_pool_index - 1).fee)
Furthermore, I believe that this condition isn’t actually needed and can be removed, which would slightly boost performance. The section is checking if a UTXO can be omitted from evaluation if it has the same effective_value as the previous UTXO and the previous was already omitted. The condition in question is comparing if the fee is different between the previous and the current UTXO. The only way for the fees to be different is if the effective_value is different, however the previous condition: utxo.GetSelectionAmount() != utxo_pool.at(utxo_pool_index - 1).GetSelectionAmount()
already compared the effective_values.
Put another way, if one of the conditions is true, the UTXO shortcut can not be applied. If the effective_values where not the same, then don’t do the shortcut except if the fees are the same. But the only way fees can be different is if the effective_values are different which creates a contradiction.
Lastly, I’m struggling to understand what the motivation is to have this condition in the first place. The condition translates to: If the fee is different between the current UTXO and the previous UTXO, then exclude the current one from the selection shortcut (which as I pointed out would never happen because of the aforementioned contradiction where the effective_value and fee are conditionally dependent).