pezmaster31 / bamtools

C++ API & command-line toolkit for working with BAM data
MIT License
418 stars 153 forks source link

double-check constants (char vs unsigned char) #112

Open domibel opened 9 years ago

domibel commented 9 years ago

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

SoapZA commented 7 years ago

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.