Skip to content

fix: add missing backslash in macro definition#3085

Merged
horenmar merged 1 commit intocatchorg:develfrom
Joseph-Edwards:fix-macro-typo
Mar 30, 2026
Merged

fix: add missing backslash in macro definition#3085
horenmar merged 1 commit intocatchorg:develfrom
Joseph-Edwards:fix-macro-typo

Conversation

@Joseph-Edwards
Copy link
Copy Markdown
Contributor

@Joseph-Edwards Joseph-Edwards commented Mar 27, 2026

Description

This PR adds a missing backslash in one of the definitions of CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS. This typo was introduced in v3.8.1. The inclusion of this backslash fixes as issue we were facing in libsemigroups/libsemigroups#931 upon updating from v3.8.0 to v3.13.0.

Minimal reproducible example

The following is a minimal reproducible example that demonstrates the error being thrown in our CI pipeline:

Contents of test.cpp:

#include <string>  // for string
#include <vector>  // for vector

#pragma GCC diagnostic push
#include "catch_amalgamated.hpp"  // for TEMPLATE_TEST_CASE
#pragma GCC diagnostic pop

TEMPLATE_TEST_CASE("example", "[quick]", int, std::string) {
  std::vector<TestType> v(5);
  REQUIRE(v.size() == 5);
}

Compile command:

> clang++ -Werror -Wgnu-zero-variadic-macro-arguments -std=gnu++17 test.cpp catch_amalgamated.cpp -o test

File structure:

.
├── catch_amalgamated.cpp
├── catch_amalgamated.hpp
└── test.cpp

Expected output:
File compiles (which is achieved upon applying the changes in this PR).

Actual output:

test.cpp:8:1: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
    8 | TEMPLATE_TEST_CASE("example", "[quick]", int, std::string) {
      | ^
./catch_amalgamated.hpp:7021:39: note: expanded from macro 'TEMPLATE_TEST_CASE'
 7021 |     #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
      |                                       ^
./catch_amalgamated.hpp:6734:9: note: expanded from macro 'INTERNAL_CATCH_TEMPLATE_TEST_CASE'
 6734 |         INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEMPLATE_TEST_ ), INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEMPLATE_TEST_ ), Name, Tags, typename TestType, __VA_ARGS__ )
      |         ^
./catch_amalgamated.hpp:6712:13: note: expanded from macro 'INTERNAL_CATCH_TEMPLATE_TEST_CASE_2'
 6712 |             INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
      |             ^
./catch_amalgamated.hpp:6625:465: note: expanded from macro 'INTERNAL_CATCH_NTTP_GEN'
 6625 | #define INTERNAL_CATCH_NTTP_GEN(...) INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__),INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_0)
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ^
./catch_amalgamated.hpp:6508:9: note: macro 'INTERNAL_CATCH_VA_NARGS_IMPL' defined here
 6508 | #define INTEclang++ --version
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/binRNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
      |         ^
test.cpp:8:1: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
    8 | TEMPLATE_TEST_CASE("example", "[quick]", int, std::string) {
      | ^
./catch_amalgamated.hpp:7021:39: note: expanded from macro 'TEMPLATE_TEST_CASE'
 7021 |     #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
      |                                       ^
./catch_amalgamated.hpp:6734:9: note: expanded from macro 'INTERNAL_CATCH_TEMPLATE_TEST_CASE'
 6734 |         INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEMPLATE_TEST_ ), INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEMPLATE_TEST_ ), Name, Tags, typename TestType, __VA_ARGS__ )
      |         ^
./catch_amalgamated.hpp:6724:22: note: expanded from macro 'INTERNAL_CATCH_TEMPLATE_TEST_CASE_2'
 6724 |             TestName<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
      |                      ^
./catch_amalgamated.hpp:6494:20: note: expanded from macro 'INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES'
 6494 |     CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__)
      |                    ^
./catch_amalgamated.hpp:6508:9: note: macro 'INTERNAL_CATCH_VA_NARGS_IMPL' defined here
 6508 | #define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
      |         ^
test.cpp:8:1: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
    8 | TEMPLATE_TEST_CASE("example", "[quick]", int, std::string) {
      | ^
./catch_amalgamated.hpp:7021:39: note: expanded from macro 'TEMPLATE_TEST_CASE'
 7021 |     #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
      |                                       ^
./catch_amalgamated.hpp:6734:9: note: expanded from macro 'INTERNAL_CATCH_TEMPLATE_TEST_CASE'
 6734 |         INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEMPLATE_TEST_ ), INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEMPLATE_TEST_ ), Name, Tags, typename TestType, __VA_ARGS__ )
      |         ^
./catch_amalgamated.hpp:6724:22: note: expanded from macro 'INTERNAL_CATCH_TEMPLATE_TEST_CASE_2'
 6724 |             TestName<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
      |                      ^
./catch_amalgamated.hpp:6494:20: note: expanded from macro 'INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES'
 6494 |     CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__)
      |                    ^
./catch_amalgamated.hpp:6508:9: note: macro 'INTERNAL_CATCH_VA_NARGS_IMPL' defined here
 6508 | #define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
      |         ^
3 errors generated.

Other useful information:

> clang++ --version
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Testing

I have tested locally that the changes in this PR fix the errors outlined above; however, I wasn't sure how to add tests to the Catch2 test suite that illustrate this. I'd be happy to add tests here with a little bit of guidance!

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.37%. Comparing base (ccc49ba) to head (985db5c).
⚠️ Report is 1 commits behind head on devel.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3085      +/-   ##
==========================================
+ Coverage   91.34%   91.37%   +0.03%     
==========================================
  Files         204      204              
  Lines        8899     8899              
==========================================
+ Hits         8128     8131       +3     
+ Misses        771      768       -3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@horenmar
Copy link
Copy Markdown
Member

Thanks.

I don't think you need to add tests for this change. It would be nice to have tests that the various warning suppressions are getting picked up properly, but I don't think it would be worth the effort to implement them; this is the first time I remember seeing the formatting of the suppression macros get broken like this.

@horenmar horenmar merged commit 2ec64d1 into catchorg:devel Mar 30, 2026
3 checks passed
@Joseph-Edwards Joseph-Edwards deleted the fix-macro-typo branch March 31, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants