Does not work in C++23 due to conflicts with import std cxx modules

オープン
#2,969 コメント 7 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
testing-qa

調査の方向性

Clang 19 または GCC 15 で C++23 import std を使用した、報告されている Module.cpp の再現から始め、その後、issue で言及されている header-only と amalgamated hpp のインクルードを調査します。ユーザーが Catch2 の標準ライブラリの include を無効化でき、再現で ODR 違反が報告されなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug
In past discussions, Catch2 devs explained that it's not possible to migrate the project for CXX Modules, because modules cannot export macros, which is correct (https://github.com/catchorg/Catch2/issues/2299). However, even if the user has cxx modules in its code, specially C++23 import std, then it cannot currently interoperate with header only catch2, because it imposes its #include , generating ODR with import std, if compiler is not "smart enough" (which is currently the case and maybe will never be fully solved).
My problem now is that I'm a long time Catch2 user, and I cannot make it work with Clang 19 or GCC 15, because I'm using import std on C++23 and that's incompatible with current Catch2 design (but it's easy to solve!).

Expected behavior
Catch2 should provide some way to disable its #include for STD things, for example, adding an option or macro like "CATCH2_DISABLE_STD_INCLUDE"... so , all #include should be surrounded by this option:

#ifndef CATCH2_DISABLE_STD_INCLUDE
#include <string>
#include <vector>
#endif

Macro name can also be CATCH_USE_STDLIB_MODULE, as in, https://github.com/catchorg/Catch2/issues/2575, but I don't know if Catch2 is interested in really using import std... maybe not! But this proposal here is simpler, it just allows users to choose between its own import std or the current Catch2 #include dependencies.

Reproduction steps
Create some Module.cpp file, with import std, and try to #include catch2, or try to link against it. ODR violations will be reported.

Platform information:

  • OS: Ubuntu Linux
  • Compiler: Clang 19 or GCC 15

Additional context
If necessary, I can do the PR... specially, for the amalgamated hpp file, it would be nice to disable all its header inclusions.

主要言語
C++
スター
21.6k
フォーク
3.4k
平均マージ
3日 12時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

catchorg/Catch2 のほかの issue

catchorg/Catch2 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。