Skip to content

Commit

Permalink
Fix gcc 7 optimization bug.
Browse files Browse the repository at this point in the history
For some reason, gcc 7 tries to optimize a function kmer canonical encoding too much,
resulting in a warning that gets turned into an error:

error: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Werror=strict-overflow]
         if( l + 2 >= k )

for the case in encode_gapped_palindrome_() where l==k.
So here we instead set l to k now, in the hope that this fixes the
issue.
  • Loading branch information
lczech committed Aug 26, 2024
1 parent bcb623a commit a1d578b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/genesis/sequence/kmer/canonical_encoding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,17 @@ class MinimalCanonicalEncoding
}

inline uint64_t encode_gapped_palindrome_(
uint64_t const val_km, int const l
uint64_t const val_km, int l
) const {
// Palindrome -> nothing to do.
// Can only occurr in even k.
auto const k = Kmer<Tag>::k();
assert( k % 2 == 0 );
assert( l >= k );
(void) l;

// We use l = k here, as l might overshoot.
return encode_prime_( val_km, k );
l = k;
return encode_prime_( val_km, l );
}

inline uint64_t encode_prime_( uint64_t const val, int const l ) const
Expand Down

0 comments on commit a1d578b

Please sign in to comment.