catchorg / catchorg/Catch2

SegFault in REQUIRE() when compiled by MSVC for x86 in Release mode

Open
#1,994 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

Recently I decided to migrate my projects from using [cxxtext](https://github.com/CxxTest/cxxtest) to catch2, mostly because the former hasn't been updated / maintained for a while and latest MSVC2019 compiler start reporting various warnings inside.

The conversion is pretty simple with replacement of `TS_ASSRT()` with `REQUIRE()` macro and test function replaced with `TEST_CASE()`. However, when compiled with MSVC for 32bit (x86) architecture in release mode (-DCMAKE_BUILD_TYPE=Release) `SegFault` is reported in some cases.

For example I have the code with 3 sequential `REQUIRE()` statements, each and every one is working fine (when others are commented out), but if there are two or more one of them causes the fault. The failure is consistent with all the VS2015, VS2017, and VS2019 compilers. Note, that the same comparisons with `TS_ASSERT()` macro worked fine with [cxxtext](https://github.com/CxxTest/cxxtest). Looks like the optimizations are too aggressive and work incorrectly for the catch2 code.

I've also noticed that your [appveyor](https://ci.appveyor.com/project/catchorg/catch2) configuration doesn't test `Win32` in `Release` mode. Is it on purpose? Is the reported problem a known issue? Have you tried to debug it and/or report to Microsoft?

Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.