Sometimes for loops containing Catch sections segfault/internal assert fail #816
Description
Description
Sometimes for loops containing Catch sections execute fine, sometimes they don't. I've been writing some like this without running into this before, so something's unique about this layout. Granted, this sample code could easily be "unrolled" so there's no for loop , or be implemented using a function or fixture. But, I've found it useful to be able to do this especially when deep in a BDD structure. And, the part in the for loop can be quite large, and the cases can be more, so unrolling can be painful.
Steps to reproduce
This compiles but fails to execute. Without debug, it segfaults. With debug, it fails an internal catch assertion: catch.hpp:5983: void Catch::TestCaseTracking::TrackerBase::moveToParent(): Assertion `m_parent' failed.
#include <catch.hpp>
TEST_CASE("") {
for(int a = 0; a < 2; ++a) {
SECTION("1") {
SECTION("A") {
}
SECTION("B") {
}
}
}
}
Moving the for loop into the first section allows it to compile and successfully execute.
#include <catch.hpp>
TEST_CASE("") {
SECTION("1") {
for(int a = 0; a < 2; ++a) {
SECTION("A") {
}
SECTION("B") {
}
}
}
}
But, moving the failing code within a section still fails to execute.
#include <catch.hpp>
TEST_CASE("") {
SECTION("Added") {
for(int a = 0; a < 2; ++a) {
SECTION("1") {
SECTION("A") {
}
SECTION("B") {
}
}
}
}
}
Extra information
- Catch version: Sort of v1.7.1 (current git master: 4d0cd60) -- I tried a really old commit from 12 months ago, and it still failed.
- Operating System: Arch Linux
- Compiler+version: clang++ 3.9.1 & g++ 6.3.1