hppa: Fix undefined behaviour in feclearexcept (BZ 30983)
commitd0829302728954e0abacfc01551c17daf4d61c87
authorBruno Haible <bruno@clisp.org>
Thu, 2 Nov 2023 19:19:44 +0000 (2 16:19 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 19 Dec 2023 18:12:38 +0000 (19 15:12 -0300)
tree931ddfa8eee1f5bf55078f807d287773bdb9febe
parent80a40a9e14d9a01e3f70c5b37ecd1da83033b6de
hppa: Fix undefined behaviour in feclearexcept (BZ 30983)

The expression

  (excepts & FE_ALL_EXCEPT) << 27

produces a signed integer overflow when 'excepts' is specified as
FE_INVALID (= 0x10), because
  - excepts is of type 'int',
  - FE_ALL_EXCEPT is of type 'int',
  - thus (excepts & FE_ALL_EXCEPT) is (int) 0x10,
  - 'int' is 32 bits wide.

The patched code produces the same instruction sequence as
previosuly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
sysdeps/hppa/fpu/fclrexcpt.c