You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Each kind of machine has a default for what char should be. It is either like unsigned char by default or like signed char by default.
Ideally, a portable program should always use signed char or unsigned char when it depends on the signedness of an object. But many programs have been written to use plain char and expect it to be signed, or expect it to be unsigned, depending on the machines they were written for. This option, and its inverse, let you make such a program work with the opposite default.
The type char is always a distinct type from each of signed char or unsigned char, even though its behavior is always just like one of those two."
For GLIMPSE what this means is that if it is compiled with a compiler or machine that defaults char to unsigned, multiple tests will fail, see the example below :
The value is used in void phasing_hmm::forward() and void phasing_hmm::backward() e.g., :
if (VAR_TYP[curr_idx_locus] >= VAR_PEAK_HET) {
if (curr_idx_locus == (VAR_TYP.size()-1)) INIT_PEAK_HET(VAR_TYP[curr_idx_locus]);
elseif (curr_segment_locus != (segments[curr_segment_index]-1)) RUN_PEAK_HET(VAR_TYP[curr_idx_locus]);
elseCOLLAPSE_PEAK_HET(VAR_TYP[curr_idx_locus]);
} elseif (VAR_TYP[curr_idx_locus] == VAR_PEAK_HOM) {
if (curr_idx_locus == (VAR_TYP.size()-1)) INIT_PEAK_HOM(VAR_ALT[curr_idx_locus]);
elseif (curr_segment_locus != (segments[curr_segment_index]-1)) RUN_PEAK_HOM(VAR_ALT[curr_idx_locus]);
elseCOLLAPSE_PEAK_HOM(VAR_ALT[curr_idx_locus]);
} elseif (VAR_TYP[curr_idx_locus] == VAR_FLAT_HET) {
if (curr_idx_locus == (VAR_TYP.size()-1)) INIT_FLAT_HET();
elseif (curr_segment_locus != (segments[curr_segment_index]-1)) RUN_FLAT_HET();
elseCOLLAPSE_FLAT_HET();
} else vrb.error("Unknown variant type in phasing backward pass at variant " + stb.str(curr_idx_locus));
If char is unsigned the test if (VAR_TYP[curr_idx_locus] >= VAR_PEAK_HET) will always succeed as VAR_PEAK_HET is defined as 0. This is not the desired behaviour.
The text was updated successfully, but these errors were encountered:
rwk-unil
added a commit
to rwk-unil/GLIMPSE
that referenced
this issue
Nov 13, 2024
The
phasing_hmm
class definesstd::vector < char > VAR_TYP;
it uses this to hold signed values for example :The problem is that the C/C++ standard does not define
char
to be signed or unsigned.See : https://stackoverflow.com/questions/2054939/is-char-signed-or-unsigned-by-default
This is also documented in the GCC manual here https://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/C-Dialect-Options.html :
"Each kind of machine has a default for what char should be. It is either like unsigned char by default or like signed char by default.
Ideally, a portable program should always use signed char or unsigned char when it depends on the signedness of an object. But many programs have been written to use plain char and expect it to be signed, or expect it to be unsigned, depending on the machines they were written for. This option, and its inverse, let you make such a program work with the opposite default.
The type char is always a distinct type from each of signed char or unsigned char, even though its behavior is always just like one of those two."
For GLIMPSE what this means is that if it is compiled with a compiler or machine that defaults
char
to unsigned, multiple tests will fail, see the example below :The value is used in
void phasing_hmm::forward()
andvoid phasing_hmm::backward()
e.g., :If
char
is unsigned the testif (VAR_TYP[curr_idx_locus] >= VAR_PEAK_HET)
will always succeed asVAR_PEAK_HET
is defined as0
. This is not the desired behaviour.The text was updated successfully, but these errors were encountered: