catchorg / catchorg/Catch2

When the same SECTION is encountered multiple times in one cycle, catch crashes on assert

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

Description

**Describe the bug**

Suppose we have nested SECTIONs in a helper function and call that function from one TEST_CASE, from the same section. Then the same sections are entered multiple times (because they have the same name and location). The same could be achieved by a loop.

In that scenario, Catch asserts/segfaults (see the attached compiler explorer link).

**Expected behavior**

Either it should work "as expected", or it should error out with a reasonable error message. Also, the documentation of `SECTION` should include clear warning that this is not supported (also a link to `DYNAMIC_SECTION` would be handy).

**Reproduction steps**

https://godbolt.org/z/rMP8vf6xe

**Platform information:**

- Catch version: devel

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.