Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invert_mask descriptor inverts return value to true for unassigned elements #316

Open
aleksamilisavljevic opened this issue Feb 26, 2024 · 0 comments · May be fixed by #317
Open

invert_mask descriptor inverts return value to true for unassigned elements #316

aleksamilisavljevic opened this issue Feb 26, 2024 · 0 comments · May be fixed by #317
Labels
invalid This doesn't seem right

Comments

@aleksamilisavljevic
Copy link
Contributor

According to the documentation:

* @return If the descriptor does not include grb::descriptors::structural
* nor grb::descriptors::structural_complement and if \a assigned
* is false, then the entry is ignored and uninterpreted, thus
* returning \a false.
* @return If the descriptor includes grb::descriptors::invert_mask,
* returns the negation of the dereferenced value of \a val
* which is first cast to a \a bool.
* @return Otherwise, returns the dereferenced value of \a val,
* cast to a \a bool.

However, if the descriptor invert_mask is set and assigned is set to false, then the return value will be true:

bool ret = false;
// if we request a structural mask, decide only on passed assigned variable
if( descriptor & descriptors::structural ) {
ret = assigned;
} else {
// if based on value, if there is a value, cast it to bool
if( assigned ) {
ret = static_cast< bool >( val[ offset ] );
}
// otherwise there is no value and false is assumed
}
// check whether we should return the inverted value
if( descriptor & descriptors::invert_mask ) {
return !ret;
} else {
return ret;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
1 participant