Repository navigation
Doesn't seem to work with Clang C++20 modules #4002
Copy link
Copy link
Closed
Labels
kind: bugsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Milestone
Description
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/ndqTvEzGjError 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
- The bug also occurs if the latest version from the
developbranch is used. - I can successfully compile and run the unit tests.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind: bugsolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Activity
LecrisUT commentedon May 9, 2023
Could this be an issue with
#includeorders 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 explicitstatic 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 withstatic_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.nlohmann commentedon May 21, 2025
This issue should have been fixed by merging #4764. Please check with the latest
developbranch.