Skip to content

Clang 22 error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions] #3076

@offa

Description

@offa

Describe the bug

Build tests with Clang 22 causes '__COUNTER__' is a C2y extension warnings on all usages of TEST_CASE(…).

Simplified example:

#include <catch2/catch_test_macros.hpp>

// ...

TEST_CASE("Connection tests", "[ConnectionTests]") { // <<<-- Line 66
    // ...
}

Compilation result:

__w/seasocks/seasocks/src/test/c/ConnectionTests.cpp:66:1: error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions]
   66 | TEST_CASE("Connection tests", "[ConnectionTests]") {
      | ^
/__w/seasocks/seasocks/build/_deps/catch2-src/src/catch2/../catch2/catch_test_macros.hpp:151:28: note: expanded from macro 'TEST_CASE'
  151 |   #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
      |                            ^
/__w/seasocks/seasocks/build/_deps/catch2-src/src/catch2/../catch2/internal/catch_test_registry.hpp:118:35: note: expanded from macro 'INTERNAL_CATCH_TESTCASE'
  118 |         INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__ )
      |                                   ^
/__w/seasocks/seasocks/build/_deps/catch2-src/src/catch2/../catch2/internal/catch_unique_name.hpp:15:85: note: expanded from macro 'INTERNAL_CATCH_UNIQUE_NAME'
   15 | #  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
      |                                                                                     ^

Expected behavior

No error or warning emitted.

Reproduction steps

  1. Build a test with Clang 22

Platform information:

  • OS: Linux
  • Compiler+version: Clang 22.1.1
  • Catch version: v3.13.0

Additional context

Enabled compiler warnings: -Wall -Werror -Wextra -pedantic -pedantic-errors

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions