Skip to content

Commit

Permalink
Change Word64 type from long long to unsigned long long
Browse files Browse the repository at this point in the history
The following change is required to solve undefined behavior detected by
UBSan.

    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:17:22
    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:18:22
    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:19:22
    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:20:22
    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:21:22
    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:22:22
    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:23:22
    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:24:22
    405 EventFilter/ESRawToDigi/src/ESUnpacker.cc:25:22

~Word64(0) is -1 and left shifting a negative number is undefined
behavior by C++.

These produce 3645 runtime errors from UBSan on full matrix. That's ~15%
of all detected runtime errors.

Word32 is defined as unsigned type. Keep it consistent and define
Word64 as unsigned long long, thus resolved undefined behavior.

Looking at the code these 64-bit masks are not used outside this package
and they are only used with bitwise and operators. The change should not
have any side effects.

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
  • Loading branch information
David Abdurachmanov authored and David Abdurachmanov committed Sep 21, 2014
1 parent d55cbb9 commit 20ac404
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion EventFilter/ESRawToDigi/interface/ESUnpacker.h
Expand Up @@ -27,7 +27,7 @@ class ESUnpacker {
public :

typedef unsigned int Word32;
typedef long long Word64;
typedef unsigned long long Word64;

ESUnpacker(const edm::ParameterSet& ps);
~ESUnpacker();
Expand Down

0 comments on commit 20ac404

Please sign in to comment.