<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/100924>100924</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clangd+modules] Clangd reports ODR violation when including iostream from (global module fragment of) two different modules
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          alfaix
      </td>
    </tr>
</table>

<pre>
    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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVkGP2zgP_TXKhYghS46dHHJI4gYt8AFfUXTPgWzTtrqy5JXkZObS376Q7CTTbtvtAoOZCSWRj-R7ZIRzstOIe7I5kk25EpPvjd0L1Qr5sqpM87p_j6-EneADYcUA3r5K3YE30KGHwTSTQhc-3oz9E27S91ArobsGWqOUuYXLZHP0vXTw8RPZlIRte-9H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