https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99190
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- It is UB only in C++17 or earlier, so one way to "fix" it is build libubsan with -std=gnu++20. Or the SIntMax(Val) << ExtraBits >> ExtraBits can be replaced by SIntMax(UIntMax(Val) << ExtraBits) >> ExtraBits.