Skip to content

Commit

Permalink
Merge pull request #46535 from smuzaffar/ubsan-ReduceMantissaToNbitsR…
Browse files Browse the repository at this point in the history
…ounding-suppress-shift

[UBSAN]Suppess -ve shift error for ReduceMantissaToNbitsRounding
  • Loading branch information
cmsbuild authored Oct 29, 2024
2 parents 5754132 + cd9abc7 commit ce5ea58
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions DataFormats/Math/interface/libminifloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class MiniFloatConverter {

class ReduceMantissaToNbitsRounding {
public:
#ifdef CMS_UNDEFINED_SANITIZER
//Supress UBSan runtime error about -ve shift. This happens when bits==23
__attribute__((no_sanitize("shift")))
#endif
ReduceMantissaToNbitsRounding(int bits)
: shift(23 - bits), mask((0xFFFFFFFF >> (shift)) << (shift)), test(1 << (shift - 1)), maxn((1 << bits) - 2) {
assert(bits <= 23); // "max mantissa size is 23 bits"
Expand Down

0 comments on commit ce5ea58

Please sign in to comment.