-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[C++23] [Modules] -fskip-odr-check-in-gmf
results in "redefinition of concept" error
#87609
Comments
@llvm/issue-subscribers-clang-modules Author: Jan Kokemüller (jiixyj)
I'm testing with LLVM/Clang head (607b4bc). I have some code where I `#include` _after_ doing an `import`:
import utpp;
#include <fstream>
#include <numeric>
#include <streambuf>
#include <string> When compiling with /llvm-project/prefix/bin/clang++ -m64 -stdlib=libc++ -Xclang -fskip-odr-check-in-gmf -Wno-deprecated-declarations -O2 -g -DNDEBUG -std=c++23 -fcolor-diagnostics -MD -MT example/CMakeFiles/utpp_gherkin_feature.dir/gherkin.cpp.o -MF example/CMakeFiles/utpp_gherkin_feature.dir/gherkin.cpp.o.d @<!-- -->example/CMakeFiles/utpp_gherkin_feature.dir/gherkin.cpp.o.modmap -o example/CMakeFiles/utpp_gherkin_feature.dir/gherkin.cpp.o -c /home/jan/git/utpp/example/gherkin.cpp
In file included from /home/jan/git/utpp/example/gherkin.cpp:9:
In file included from /llvm-project/prefix/bin/../include/c++/v1/fstream:199:
In file included from /llvm-project/prefix/bin/../include/c++/v1/filesystem:538:
In file included from /llvm-project/prefix/bin/../include/c++/v1/__filesystem/directory_entry.h:20:
In file included from /llvm-project/prefix/bin/../include/c++/v1/__filesystem/filesystem_error.h:15:
In file included from /llvm-project/prefix/bin/../include/c++/v1/__filesystem/path.h:30:
In file included from /llvm-project/prefix/bin/../include/c++/v1/iomanip:46:
In file included from /llvm-project/prefix/bin/../include/c++/v1/istream:170:
In file included from /llvm-project/prefix/bin/../include/c++/v1/ostream:188:
In file included from /llvm-project/prefix/bin/../include/c++/v1/format:194:
In file included from /llvm-project/prefix/bin/../include/c++/v1/__format/container_adaptor.h:20:
In file included from /llvm-project/prefix/bin/../include/c++/v1/__format/range_default_formatter.h:23:
In file included from /llvm-project/prefix/bin/../include/c++/v1/__format/range_formatter.h:23:
In file included from /llvm-project/prefix/bin/../include/c++/v1/__format/format_context.h:30:
/llvm-project/prefix/bin/../include/c++/v1/optional:565:9: error: redefinition of concept '__is_derived_from_optional' with different template parameters or requirem
ents
565 | concept __is_derived_from_optional = requires(const _Tp& __t) { []<class _Up>(const optional<_Up>&) {}(__t); };
| ^
/llvm-project/prefix/bin/../include/c++/v1/__ranges/movable_box.h:21:10: note: '/llvm-project/prefix/bin/../include/c++/v1/optional' inclu
ded multiple times, additional include site in header from module 'std.<global>'
21 | #include <optional>
| ^
/llvm-project/prefix/share/libc++/v1/std.cppm:14:1: note: std.<global> defined here
14 | module;
| ^
/llvm-project/prefix/bin/../include/c++/v1/__format/format_context.h:30:12: note: '/llvm-project/prefix/bin/../include/c++/v1/optional' in
cluded multiple times, additional include site here
30 | # include <optional>
| ^ When compiling with Another data point: on LLVM/Clang from 2024-02-22, this compiled without error without any additional compiler arguments. So now, I have to do one of the following to make the error go away:
Has anyone an idea how/why this could happen? I could try to bisect this, but this could take a while... |
I guess the reason may be that we used ODRHash to merge concepts in (import-before-include) path. A reduced (without any stl) may be helpful. |
Although I marked this as closed in the commit, I didn't try the original reproducer. So feel free to reopen this if there is still problems. |
Thank you! I can confirm that the fix works. I tested with 8cee94e . |
I'm testing with LLVM/Clang head (607b4bc). I have some code where I
#include
after doing animport
:When compiling with
-fskip-odr-check-in-gmf
(which is the default now, I think), I'm getting a "redefinition of concept" error:When compiling with
-fno-skip-odr-check-in-gmf
, it finishes compiling without error. Which is curious, since I had assumed that enabling-fskip-odr-check-in-gmf
would always result in less errors, not more.Another data point: on LLVM/Clang from 2024-02-22, this compiled without error without any additional compiler arguments.
So now, I have to do one of the following to make the error go away:
-fno-skip-odr-check-in-gmf
import
after the#include
sHas anyone an idea how/why this could happen? I could try to bisect this, but this could take a while...
The text was updated successfully, but these errors were encountered: