And that is the proper solution. The problem is wider than just log10:
Modern Delphi masks all floating point exceptions and that is as per IEEE754-2019. Most other compilers do.
Delphi has provided a Legacy mask to avoid breaking older code. (Well, that is the least they could do because it is, as I explained, a breaking change.)
So the fix should never be for just log10. Further more, fixing it at fpu level is much faster than above code: flags as opposed to a relatively expensive comparison.
I decided to write a bug report after all, since the issue is more like hindsight from the standards commission than it is a Freepascal issue perse.
Applying the mask is valid for all cases where a division by zero/ and/or +/-inf/NaN can occur.
I reported it as :
#41341
Note, as I explained in the bug report, it is not a bug perse' but an implementation consideration.