Issue 100924
Summary [clangd+modules] Clangd reports ODR violation when including iostream from (global module fragment of) two different modules
Labels new issue
Assignees
Reporter alfaix
    Hey, I'm trying to get modules to work with clangd following [this PR](https://github.com/llvm/llvm-project/pull/66462).

However, when I run `clangd` with the following files:
```cpp
// b.cppm
module;
#include <iostream>
export module b;

export template <class T>
concept C = requires() {
  { T::foo } -> std::convertible_to<int>;
};

// c.cppm
module;

#include <iostream>

export module c;
import b;
class B {
public:
 static constexpr int foo = 1;
};

export template <class T>
 requires C<T>
class D {};

int main() { D<B> s; }
```

Put `-std=c++23 -stdlib=libc++` and all the `-fmodule` things in `compile_commands.json`, clangd reports an ODR violation, saying the 2 definitions of `std::error_category` from the 2 includes are different: `E[12:04:26.095] [module_odr_violation_missing_decl] Line 3: in included file: 'std::error_category::message' from module '' is not present in definition of 'std::error_category' in module 'b.<global>'`

The setup is sensitive to small changes - e.g., removing std::convertible from the concept leads to the error disappearing. I put the repro in a [small repo](https://github.com/alfaix/clangd-odr-repro) for convenience.

Tested with `Ubuntu clang version 20.0.0 (++20240727042143+9a3e66e314e6-1~exp1~20240727042317.1828)` straight out of apt.llvm.org snapshot repo.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to