Skip to content

Commit

Permalink
Merge pull request #5 from swift-nav/woodfell/disable_ubsan
Browse files Browse the repository at this point in the history
Disable specific ubsan checks for a handful of functions
  • Loading branch information
woodfell authored Dec 8, 2022
2 parents 1b7d4dd + 8a7ecb7 commit 40f05f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion include/rapidcheck/detail/BitStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ T BitStream<Source>::next(int /*nbits*/, std::true_type) {

template <typename Source>
template <typename T>
T BitStream<Source>::next(int nbits, std::false_type) {
T BitStream<Source>::next(int nbits, std::false_type)
#ifdef __clang__
__attribute__((no_sanitize("implicit-signed-integer-truncation")))
__attribute__((no_sanitize("implicit-integer-sign-change")))
#endif
{
using SourceType = decltype(m_source.next());

if (nbits == 0) {
Expand Down
6 changes: 5 additions & 1 deletion include/rapidcheck/detail/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ inline uint64_t avalanche(uint64_t x) {
/// Returns a bitmask of the given type with the lowest `nbits` bits set to 1
/// and the rest set to 0.
template <typename T>
constexpr T bitMask(int nbits) {
constexpr T bitMask(int nbits)
#ifdef __clang__
__attribute__((no_sanitize("unsigned-shift-base")))
#endif
{
using UT = typename std::make_unsigned<T>::type;
using UTP = typename std::common_type<UT, unsigned>::type;
// There are two pieces of undefined behavior we're avoiding here,
Expand Down
6 changes: 5 additions & 1 deletion src/Random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ void Random::append(bool x) {
m_bitsi++;
}

void Random::mash(Block &output) {
void Random::mash(Block &output)
#ifdef __clang__
__attribute__((no_sanitize("unsigned-shift-base")))
#endif
{
// Input
uint64_t b0 = m_bits;
uint64_t b1 = m_counter;
Expand Down

0 comments on commit 40f05f8

Please sign in to comment.