rapidcheck icon indicating copy to clipboard operation
rapidcheck copied to clipboard

Fail to run any rapidcheck tests in Visual Studio 2017 (15.7.*)

Open o-mdr opened this issue 7 years ago • 2 comments

None of my tests run after an update to VS2017 15.7.0 (and also 15.7.1). To reproduce, I copy-pasted code from the example ( rapidcheck/examples/gtest/main.cpp)

RC_GTEST_PROP(MyTestCase,
    copyOfStringIsIdenticalToOriginal,
    (const std::string &str)) {
    RC_CLASSIFY(str.empty());
    const auto strCopy = str;
    RC_ASSERT(strCopy == str);
}

This fails with

unknown file: error: SEH exception with code 0xc0000005 thrown in the test body.

I run tests in Debug and traced this to Serialization.hpp

template <typename T, typename Iterator>
Iterator serializeCompact(T value, Iterator output) {
  static_assert(std::is_integral<T>::value, "T must be integral");

  using UInt = typename std::make_unsigned<T>::type;
  auto uvalue = static_cast<UInt>(value);
  do {
    auto x = uvalue & 0x7F;
    uvalue = uvalue >> 7;
    *output = static_cast<std::uint8_t>((uvalue == 0) ? x : (x | 0x80));      <<<<<<<<< HERE uvalue is 0
    output++;
  } while (uvalue != 0);

  return output;
}

image

o-mdr avatar May 14 '18 11:05 o-mdr

Unable to look into this myself right now, if you have the time yourself, a PR will greatly be appreciated.

emil-e avatar May 15 '18 07:05 emil-e

Turns out this is a breaking change in the compiler, see this issue.

I've recompiled rapidcheck with VS 15.7.1, updated .lib files in my project and recompiled my project. The errors went away.

Everyone loves those pesky compiler quirks :/

o-mdr avatar May 15 '18 11:05 o-mdr