Issue #27507: Merge overflow check from 3.5