]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix unexpected overflow check before fixed-point multiplication
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 26 Sep 2025 17:45:10 +0000 (19:45 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 28 Oct 2025 10:24:05 +0000 (11:24 +0100)
commitf714e1baf8804dfcff5bf9f23cd548c2c2e32a40
tree0ef7927076fc5a7bf4e14358a610fc881f6abea4
parente863ad5cc2c846c10765c81f054cc07c3008e30e
ada: Fix unexpected overflow check before fixed-point multiplication

The problem is that the code generating the fixed-point multiply uses the
subtypes of the operands to size the operation, while operations are to be
performed in base types, which are signed per the RM 3.5.9(12) subclause.
As a consequence, when the subtypes are fully asymmetric unsigned, the size
is too small and an incorrect overflow check is generated.

The code generating the divide was fixed a long time ago, this aligns the
code generating the multiply and the code generating the remainder, which
in turn requires a couple of adjustments to related routines.

gcc/ada/ChangeLog:

PR ada/122063
* exp_fixd.adb (Build_Double_Divide_Code): Convert the result of the
multiply.
(Build_Multiply): Use base types of operands to size the operation.
(Build_Rem): Likewise.
(Build_Scaled_Divide_Code): Convert the result of the multiply.
gcc/ada/exp_fixd.adb