bamtools icon indicating copy to clipboard operation
bamtools copied to clipboard

double-check constants (char vs unsigned char)

Open domibel opened this issue 9 years ago • 1 comments

Please double-check the constants in https://github.com/pezmaster31/bamtools/blob/master/src/api/BamConstants.h

// zlib & BGZF constants const char GZIP_ID1 = 31; const char GZIP_ID2 = 139; const char CM_DEFLATE = 8; const char FLG_FEXTRA = 4; const char OS_UNKNOWN = 255; const char BGZF_XLEN = 6; const char BGZF_ID1 = 66; const char BGZF_ID2 = 67; const char BGZF_LEN = 2;

Two values don't fit in 'char' [-128,127] const char GZIP_ID2 = 139; const char OS_UNKNOWN = 255;

The integer conversion results in a change of sign -117 for GZIP_ID2 = 139 -1 for OS_UNKNOWN = 255

Best -Dominique

domibel avatar Oct 13 '15 14:10 domibel

The proper fix for this is to use unsigned fixed-width C99/C++11 cstdint variants. This will come once we switch the build system to require C++11 support.

SoapZA avatar Oct 21 '17 18:10 SoapZA