Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.10
-
None
-
1145e1709 (dev), c5608c675 (dev)
Description
qRound(double d) is documented to "Rounds d to the nearest integer.". If d is outside the range of integers (overflow), it should therefore clamp the result to INT_MAX (or INT_MIN).
Instead, it triggers UB, as it just converts the double to integer (after some adjustements), without checking whether it's in bounds or not. This is https://eel.is/c++draft/conv.fpint#1.sentence-3
This has a cascading effect, for instance the geometry classes use qRound internally, causing for instance a QRectF -> QRect conversion to also trigger UB. There's at least an autotest (tst_QRect::comparison(WithQREAL_MIN)) where this happens.