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

    <tr>
        <th>Summary</th>
        <td>
            Clang: modules and std::initializer_list do not like each other
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Clang version: 19.1.3
C++ version: 23
STL: from msvc

I was trying to compile nlohmann json using modules and I encountered an error (posting the original error for others who might google it):
```
C:\Users\username\.conan2\p\nlohm0567ffc90cfc1\p\include\nlohmann\detail\input\lexer.hpp:748:66: error: no matching constructor for initialization of 'std::initializer_list<char_int_type>' (aka 'initializer_list<int>')
  748 | if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF})))
```

I tried to reduce code to the minimum reproducible example and here's what I got (pay attention to the highlighted lines changing which kind of fixes the issue):

```
// main.cpp

import std;
import mod;

int main() {
    lexer{}.func({1,1});
    return 0;
}
```

```
// mod.cppm

module;

#include "inc.hpp"

export module mod;

export using ::lexer;
export using ::adapter;
```

<pre>
// inc.hpp

#pragma once

#include &lt;initializer_list>
#include &lt;string>

struct adapter {
    using char_type = char;
};

template&lt;typename InputAdapterType = adapter>
class lexer
{
    using char_type = typename InputAdapterType::char_type; // <b><i>if I replace InputAdapterType here with adapter everything works fine</i></b>
    using char_int_type = typename std::char_traits&lt;char_type>::int_type;

public:
    void func(std::initializer_list&lt;char_int_type> ranges) {}
};
</pre>

<pre>
// std.cppm

module;

#define _BUILD_STD_MODULE // <b><i>if I delete this line everything works fine</i></b>

#include &lt;intrin.h>

export module std;

#include &lt;initializer_list>
#include &lt;regex> // <b><i>if I delete this line everything works fine</i></b>
</pre>

<details>
<summary>The full error I get</summary>

```
C:/Users/username/CLionProjects/untitled23_1/std/modules/std.msvc.cppm:9:10: warning: '#include <filename>' attaches the declarations to the named module 'std', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
    9 | #include <initializer_list>
      | ^
C:/Users/username/CLionProjects/untitled23_1/std/modules/std.msvc.cppm:7:15: warning: 'std' is a reserved name for a module [-Wreserved-module-identifier]
    7 | export module std;
      | ^
C:/Users/username/CLionProjects/untitled23_1/std/modules/std.msvc.cppm:10:10: warning: '#include <filename>' attaches the declarations to the named module 'std', which is not usually intended; consider moving that directive before the module declaration [-Winclude-angled-in-module-purview]
   10 | #include <regex>
      |          ^
3 warnings generated.
[4/6] Building CXX object CMakeFiles/untitled23_1.dir/main.cpp.obj
FAILED: CMakeFiles/untitled23_1.dir/main.cpp.obj 
C:\Tools\llvm\bin\clang++.exe -IC:/Users/username/CLionProjects/untitled23_1/include -IC:/Users/username/CLionProjects/untitled23_1/mod/../include -IC:/Users/username/CLionProjects/untitled23_1/std/include -O0 -std=c++23 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -g -Xclang -gcodeview -MD -MT CMakeFiles/untitled23_1.dir/main.cpp.obj -MF CMakeFiles\untitled23_1.dir\main.cpp.obj.d @CMakeFiles\untitled23_1.dir\main.cpp.obj.modmap -o CMakeFiles/untitled23_1.dir/main.cpp.obj -c C:/Users/username/CLionProjects/untitled23_1/main.cpp
C:/Users/username/CLionProjects/untitled23_1/main.cpp:6:18: error: no matching constructor for initialization of 'std::initializer_list<char_int_type>' (aka 'initializer_list<int>')
    6 | lexer{}.func({1,1});
      |                  ^~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include\initializer_list:33:15: note: candidate constructor not viable: no known conversion from 'int' to 'const int *' for 1st argument
   33 |     constexpr initializer_list(const _Elem* _First_arg, const _Elem* _Last_arg) noexcept
      |               ^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include\initializer_list:21:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
   21 | class initializer_list {
 |       ^~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include\initializer_list:21:7: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
   21 | class initializer_list {
 |       ^~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include\initializer_list:31:15: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   31 |     constexpr initializer_list() noexcept : _First(nullptr), _Last(nullptr) {}
      | ^
C:\Users\username\CLionProjects\untitled23_1\mod\..\include\inc.hpp:17:52: note: passing argument to parameter 'ranges' here
   17 |     void func(std::initializer_list<char_int_type> ranges) {}
      | ^
1 error generated.
```

</details>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWV9z47YR_zTwy444JCia8oMfJEpq3dpJZs6XJk8aCFiRuCMBFgRluw_32TsASP2xddc4aTqZthrNSCQWy93fb3exAFnXyVIh3pJsQbLlFettpc3tJ_nJfa-2WrzcFjVTJezRdFIrks4huYmSKCXxvCB0QejidIy6-x8e793_ndENNN2ek3hO4vkdPLEOrHmRqgSrgeumlTWCqnXVMKXgU6cV9J0bbrToa-yAKQF3gIrrXlk0KIApQGO0AUJnre6sV1YhaCNLqVg9jO60AW0rNB08VRoaWVYWSq3LGkFaQm9I6mwi1_Hwdd6kc5IVHzs0HcmKvkOjWIMkKyKuFVOUZEVLssLbG2fX-W7Hb2K-48kwIBWve4GjCFOKZIVAy2TtR9vekqyo8RlNVLUtSef5dEbS-fW1Q8vb7f4oDQ2zvHKeca06a3puB5ekklayWv6DWakV6B0QmndWONPT-WEUzaaWnSVpwStmNlLZjX1pkaQrQnOHHPvM3MwLE6SyQcxhFM8B8ukMSF6AdM-a_eXD999t_rxa3q9-3nz87v7ur6v7nwmdEZoofLab7YvFjVQbw1SJ7n6-iJ9nMaEFxM-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