Issue 174858
Summary [C++ Modules] "import std" conflict with module that includes STL headers: std::println compilation failure
Labels libc++, clang:modules
Assignees
Reporter kaladron
    I am encountering a compilation error on x86_64 Clang 21 and Clang Trunk when using import std; alongside a user-defined named module.  The user-defined module includes 3 STL headers, and this causes a resolution failure in the main test file.

Github won't let me attach .cc or .cppm files, so I'm including them inline.

[CMakeLists.txt](https://github.com/user-attachments/files/24481535/CMakeLists.txt)

test.cc:
```
import std;
import header_wrapper;

int main() {
 // This should work but causes compilation errors with LLVM
 std::println("Testing std::println after importing header_wrapper");
 
 return 0;
}
```

header_wrapper.cppm:
```
// Module that wraps the header library
module;

#include <chrono>
#include <cstddef>
#include <ostream>

export module header_wrapper;

export void f1(std::size_t);
```

These seem to be the relevant errors during compilation:

```
In module 'std' imported from /app/test.cc:1:
.../format_functions.h:99:30: error: call to implicitly-deleted default constructor of 'formatter<std::__1::basic_format_string<char>, char>'
   99 | formatter<_Tp, _CharT> __f;
...
test.cc:6:7: note: in instantiation of function template specialization 'std::__1::println<>' requested here
    6 |  std::println("Testing std::println after importing header_wrapper");
```

But I've also attached the full build error:

[buildlog.txt](https://github.com/user-attachments/files/24482026/buildlog.txt)

h/t to @dwblaikie who helped me further reduce my test case and helped me with godbolt: https://godbolt.org/z/GMaaqvPrK where we tested this with Clang 21 and Clang trunk.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to