Issue 156604
Summary [clang] libstdc++ headers and module conflict
Labels
Assignees
Reporter rdong8
    Posting [this issue](https://stackoverflow.com/questions/79753528/weird-interaction-between-libstdc-standard-library-headers-and-module) here. Using LLVM 21.1.0 with libstdc++ from gcc 15.1.0 and `-std=c++23`, this compiles:

```cpp
#include <memory>
#include <string>

import std;

auto main() -> int { [[maybe_unused]] std::shared_ptr<std::string> ptr{}; }
```

But this doesn't:

```cpp
module;

#include <memory>
#include <string>

export module main;

import std;

auto main() -> int { [[maybe_unused]] std::shared_ptr<std::string> ptr{}; }
```

Example of the error:

```cpp
In file included from /workspaces/cpp_project/src/toy/tmp.cppm:3:
In file included from /usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/memory:82:
In file included from /usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr.h:53:
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr_base.h:1783:15: error: cannot befriend target of using declaration
 1783 |         friend _Del* get_deleter(const __shared_ptr<_Tp1, _Lp1>&) noexcept;
      | ^
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr.h:175:31: note: in instantiation of template class 'std::__shared_ptr<std::__cxx11::basic_string<char>>' requested here
  175 | class shared_ptr : public __shared_ptr<_Tp>
      | ^
/workspaces/cpp_project/src/toy/tmp.cppm:10:68: note: in instantiation of template class 'std::shared_ptr<std::__cxx11::basic_string<char>>' requested here
   10 | auto main() -> int { [[maybe_unused]] std::shared_ptr<std::string> ptr{}; }
 | ^
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr.h:79:5: note: target of using declaration
   79 |     get_deleter(const __shared_ptr<_Tp, _Lp>& __p) noexcept
      | ^
/usr/include/c++/15/bits/std.cc:1938:14: note: using declaration
 1938 | using std::get_deleter;
      |              ^
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to