REQUIRE(std::indirect(42) == 42) fails to compile with gcc and clang

Open
#3,073 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@akasakariko is already working on this.

Since Oct 26, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp
Domain
testing-qa

Research direction

Start with the provided test snippet on Compiler Explorer using x86-64 GCC trunk and Clang trunk with -std=c++26, reproducing the recursive constraint-satisfaction error. Trace the Catch2 expression handling involved in REQUIRE and verify completion when the test compiles and passes with std::indirect(42) == 42.

Written by the indexing model from the issue text.

Description

Describe the bug
Using Catch2 with REQUIRE(std::indirect(42) == 42) triggers a recursive constraint satisfaction error with gcc and clang.

error: satisfaction of atomic constraint 'requires(const _Tp& __t, const _Up& __u) {__t == __u;} [with _Tp = _Tp; _Up = _Up]' depends on itself

Expected behavior
REQUIRE(std::indirect(42) == 42) should compile and pass.

Reproduction steps
Build this snippet with x86-64 gcc trunk and -std=c++26

#include <catch2/catch_all.hpp>
#include <memory>

TEST_CASE( "std::indirect(42) compares equal to 42" ) {
    REQUIRE(std::indirect(42) == 42);
}

Platform information:

  • OS: Compiler Explorer
  • Compiler+version: x86-64 gcc trunk and x86-64 clang trunk
  • Catch version: Tested with trunk and 3.0.1
Dominant language
C++
Stars
21.6k
Forks
3.4k
Avg merge
3d 12h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from catchorg/Catch2

All issues in catchorg/Catch2

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.