<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63796>63796</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang-17][C++20 Modules] Different definitions of same functions in 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>
2283572185
</td>
</tr>
</table>
<pre>
I use clang-17 with target of x86_64-w64-mingw32 to compile std header units. But I get errors blow.
```
In module 'D:/Tools/gcc/include/c++/14.0.0/random':
D:/Tools/gcc/include/sec_api/stdio_s.h:309:27: error: 'sprintf_s' has different definitions in different modules; definition in module 'D:/Tools/gcc/include/c++/14.0.0/random' first difference is function body
309 | __mingw_ovr int __cdecl sprintf_s(char *_DstBuf, size_t _DstSize, const char *_Format, ...)
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310 | {
| ~
311 | __builtin_va_list _ArgList;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
312 | int _Ret;
| ~~~~~~~~~
313 | __builtin_va_start(_ArgList, _Format);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 | _Ret = _vsprintf_s_l(_DstBuf, _DstSize, _Format, NULL, _ArgList);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315 | __builtin_va_end(_ArgList);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
316 | return _Ret;
| ~~~~~~~~~~~~
317 | }
| ~
D:/Tools/gcc/include/sec_api/stdio_s.h:309:27: note: but in 'C:\Users\22835\AppData\Local\.xmake\packages\b\benchmark\1.7.0\ef2ea2997db34a0cb9be0597c54ddf80\include/benchmark/benchmark.h' found a different body
309 | __mingw_ovr int __cdecl sprintf_s(char *_DstBuf, size_t _DstSize, const char *_Format, ...)
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310 | {
| ~
311 | __builtin_va_list _ArgList;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
312 | int _Ret;
| ~~~~~~~~~
313 | __builtin_va_start(_ArgList, _Format);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314 | _Ret = _vsprintf_s_l(_DstBuf, _DstSize, _Format, NULL, _ArgList);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
315 | __builtin_va_end(_ArgList);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
316 | return _Ret;
| ~~~~~~~~~~~~
317 | }
| ~
In module 'D:/Tools/gcc/include/c++/14.0.0/random':
D:/Tools/gcc/include/sec_api/stdio_s.h:296:27: error: 'vsprintf_s' has different definitions in different modules; definition in module 'D:/Tools/gcc/include/c++/14.0.0/random' first difference is function body
296 | __mingw_ovr int __cdecl vsprintf_s(char *_DstBuf, size_t _Size, const char *_Format, va_list _ArgList)
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297 | {
| ~
298 | return _vsprintf_s_l(_DstBuf, _Size, _Format, NULL, _ArgList);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299 | }
| ~
D:/Tools/gcc/include/sec_api/stdio_s.h:296:27: note: but in 'C:\Users\22835\AppData\Local\.xmake\packages\b\benchmark\1.7.0\ef2ea2997db34a0cb9be0597c54ddf80\include/benchmark/benchmark.h' found a different body
296 | __mingw_ovr int __cdecl vsprintf_s(char *_DstBuf, size_t _Size, const char *_Format, va_list _ArgList)
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297 | {
| ~
298 | return _vsprintf_s_l(_DstBuf, _Size, _Format, NULL, _ArgList);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
299 | }
| ~
9 warnings and 2 errors generated.
```
Use msvc stl will also casue errors like these. The definitions in different modules are same, so it should not cause an error. I can use msvc or gcc to compile the code.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWE2P4jgQ_TXmUuoosUlCDhzosEgt9e5hduYcOU4l8baxke3A7Bzmt68caGAGehrtjma_OgIlscvPz2XXq6i4c7LTiHOS3pN0OeGD742dUzpjaU6TWTqpTfP7_AEGhyAU191dksNO-h48tx16MC18nGVVNr3bZdO7tdTdjlHwBoRZb6RCcL6BHnmDFgYtvYvgfvDwAGEwWmusg1qZXUTiJYkXJIsPv_H1QcPaNINCIDRfErYgdPXeGOUIXXVCELqSWqihQUJXgtD78bdKplEcxYSuLNeNWROah5Ej4CsYDkXFNzI8-UaaykU9YQsWF4QtRpQ95fBAaO42VmrfVo7QHHruoJFtixa1hwZbqaWXRjuQ-qxjvxxH2P2ZTTD5LuuEVlrnj9MJBOmgHbQYZwl7uXcDAIsLIHkJAFU17lplthak9lBVokGh4Gx1M9FzC4QuqqXz90NLaAlOfsLKQ2j5VX7C0CSMdh6Otitj19yHjiiKCC2epw5XmPrzCxdJf3qp6_brMBlL4sMySX7_NQGAz0d3JMmhKTikHqTyUldbXinpPFQL2z1K5wl7xni2fZ0BsIQezUf_vsMzoEtvnMax65Sc59YTOjuyoiUcnV18C_oWjwFLpqd536EHwpZQbY_HoVJh7tNBOD8BZ3v-y4fHx7HpyPLPU7uJdToCfuEp1M0XfrrG4LZdZEl2tLboB6tf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