Skip to content
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

Doesn't seem to work with Clang C++20 modules #4002

Open
2 tasks
rnikander opened this issue Apr 10, 2023 · 1 comment
Open
2 tasks

Doesn't seem to work with Clang C++20 modules #4002

rnikander opened this issue Apr 10, 2023 · 1 comment

Comments

@rnikander
Copy link

Description

I'm not sure if this is a bug in Clang, or in this library. I've been using C++20 modules there but they do have some problems.

https://godbolt.org/z/ndqTvEzGj

I linked to Clang 16.0.0, because as of right now, the trunk is segfaulting. It's been doing that for a few days now. But normally I use Clang trunk when I can.

Reproduction steps

Look at the godbolt example, it shows the error. It's a minimal example with no other code in the files.

Expected vs. actual results

This cryptic compiler error shouldn't be happening.

Minimal code example

https://godbolt.org/z/ndqTvEzGj

Error messages

/opt/compiler-explorer/clang-16.0.0/bin/clang++ --gcc-toolchain=/opt/compiler-explorer/gcc-12.2.0   -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 -isystem/opt/compiler-explorer/libs/nlohmann_json/trunk/single_include -g -MD -MT CMakeFiles/mod_json_bug.dir/Mod1_Impl.cc.o -MF CMakeFiles/mod_json_bug.dir/Mod1_Impl.cc.o.d @CMakeFiles/mod_json_bug.dir/Mod1_Impl.cc.o.modmap -o CMakeFiles/mod_json_bug.dir/Mod1_Impl.cc.o -c /app/Mod1_Impl.cc
In file included from /app/Mod1_Impl.cc:2:
/opt/compiler-explorer/libs/nlohmann_json/trunk/single_include/nlohmann/json.hpp:14438:13: error: no matching function for call to 'unescape'
            detail::unescape(reference_token);
            ^~~~~~~~~~~~~~~~
/opt/compiler-explorer/libs/nlohmann_json/trunk/single_include/nlohmann/json.hpp:13782:28: note: in instantiation of member function 'nlohmann::json_pointer<std::basic_string<char>>::split' requested here
        : reference_tokens(split(s))
                           ^
/opt/compiler-explorer/libs/nlohmann_json/trunk/single_include/nlohmann/json.hpp:24402:12: note: in instantiation of member function 'nlohmann::json_pointer<std::basic_string<char>>::json_pointer' requested here
    return nlohmann::json::json_pointer(std::string(s, n));
           ^

Compiler and operating system

linux, clang, or macos clang

Library version

6af826d via conan

Validation

@LecrisUT
Copy link

LecrisUT commented May 9, 2023

Could this be an issue with #include orders or is it a missing macro/concept or some other defintion somewhere? I had an issue with #include<memory> needing to be included before #include<filesystem>. Maybe there is something similar happening here.

I do confirm that I get the same error and only when using modules. Navigating the traceback, I don't see anything that should be creating such an issue. I find it weird because when I replace template<>static void unescape(StringType& s) with an explicit static void unescape(std::string& s) the problem does not manifest. I have tried moving around the code, but that makes no difference. I have even tested with static_assert(std::same_as<string_t,std::string>); and that does not fail. This could be a clang bug if you can rope some of them to take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants