Skip to content

Compilation failure with C++20 #2272

@stac47

Description

@stac47

I tried to build the tests of Catch2 with latest gcc 11.2.1 and C++20 standard.

I got those two errors:

In file included from /home/docker/opensource/Catch2/include/catch.hpp:54,
                 from /home/docker/opensource/Catch2/projects/SelfTest/UsageTests/Message.tests.cpp:9:
/home/docker/opensource/Catch2/projects/SelfTest/UsageTests/Message.tests.cpp: In function 'void ____C_A_T_C_H____T_E_S_T____76()':
/home/docker/opensource/Catch2/projects/SelfTest/UsageTests/Message.tests.cpp:245:40: error: top-level comma expression in array subscript is deprecated [-Werror=comma-subscript]
  245 |     CAPTURE(std::vector<int>{1, 2, 3}[0, 1, 2],
      |                                        ^

Which is related to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1161r3.html

/home/docker/opensource/Catch2/projects/SelfTest/UsageTests/Matchers.tests.cpp:245:38: error: 'address' has not been declared in 'class std::allocator<int>'
  245 |             using std::allocator<T>::address;
      |                                      ^~~~~~~
/home/docker/opensource/Catch2/projects/SelfTest/UsageTests/Matchers.tests.cpp:247:38: error: 'construct' has not been declared in 'class std::allocator<int>'
  247 |             using std::allocator<T>::construct;
      |                                      ^~~~~~~~~
/home/docker/opensource/Catch2/projects/SelfTest/UsageTests/Matchers.tests.cpp:249:38: error: 'max_size' has not been declared in 'class std::allocator<int>'
  249 |             using std::allocator<T>::max_size;
      |                                      ^~~~~~~~
/home/docker/opensource/Catch2/projects/SelfTest/UsageTests/Matchers.tests.cpp:250:38: error: 'destroy' has not been declared in 'class std::allocator<int>'
  250 |             using std::allocator<T>::destroy;
      |                                      ^~~~~~~

Because it has been removed in C++20 from std::allocator.

Platform:

  • OS: GNU/Linux Ubuntu 20.04
  • Compiler+version: GCC 11.2.1
  • Catch version: HEAD of v2.x branch

Regards,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueIssues that can be undertaken by someone new to the projectHelp wantedIssue outside of the maintainers expertiseWarnings issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions