<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107673>107673</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Seemingly incorrect treatment of constexpr member functions in modules
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kamrann
</td>
</tr>
</table>
<pre>
According to the standard, member functions defined within a class definition are implicitly `inline` in the global module, but not so within a module purview. However, the standard also states that `constexpr` member functions are implicitly inline, and in this case makes no exception for modules.
[11.4.2/1 [class.mfct] - see also Note 1](https://eel.is/c++draft/class.mfct#1)
[9.2.6/1 [dcl.constexpr]](https://eel.is/c++draft/dcl.constexpr#1)
As such all `constexpr` member functions should be `inline`, regardless of modules. From what I can see, clang is not respecting this. I'm seeing linker errors for such member functions when using modules with shared libraries.
I believe the difference between clang and gcc [seen here](https://godbolt.org/z/GGW1fjMT1) is fundamentally the cause. Clang is generating code for a function marked `constexpr` but not for one marked `inline constexpr`, yet if I'm interpreting the standard correctly these cases should be equivalent.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVMFu6zYQ_Br6sogg0ZZUH3SIY-g1h_bSAj2vyJXEF4p0uZT90q8vKCuxkxQo3kWCqCVndmaWyGwGR9SI8iDK4wbnOPrQvOAU0LlN5_Vr86iUD9q4AaKHOBJwRKcxaCGfYKKpowD97FQ03jFo6o0jDRcTR-MAQVnkddmkEsBAYKaTNcpE-wqiyo2zxpGocjBuQRis79DC5PVsKcF0cwTnI7C_HXz9C6c5nA1dMvjVX-hMIZXfswS07NNXJIY4YkyIyjuO9OMUEuiXHj4xXOnJJ0CnrxQNg0ImmPCFGJwH-qHotLTX-7BS4wxEfhT54_osD0WR7TIpZFuAKA-LMtnUqyjKIzwAE13J_u4jQSHKo5C_jDGeWGwfhWyFbIlsZljIVgl5EPKgA_Yxfd6OkttCyP075D6TWfWGqJXNbq2Xx5-B-Lj3A8ryfGTgWY2A1v6_wjz62Wro6IP9SeJAAwZtiRl8fxOyDX6CS3LvGRS6pFWqVhbdAIaXcATiE6m4JHU0nMGzkPWUStOSNe6FAlAIPvDi0kL3C7XLSA5mTltW9CVywCMG0mBNFzCYz-Y-Q0fW0JmW7GnT9xTIKYKO4oXIrUxTgAalkhecVkcK9F8mDF533sbMh0HI9h8h22_f_ir677_9mWRPDfez0ziRi2jt6wKqcGbK4OlNkoEcBVzkUF7T0jK-NwoThhfSX6x6m7RU7R3dlV1tgvvqZMErRTD9qrVxkcIp0GrC3RQqHwKpeOXKtIzPfQ7o79mc0ZKL2UY3W73f7nFDTVHLstrvyjrfjE3V5fm2KrCq9H6n813Zkc4L1ZWyUH1V641pZC53-T6v83pbFXlW1LWmreoQ-05uOyl2OU1obGbteUrqbgzzTE2R11W93VjsyPJyGUrp6ALLXyFluhtDkzY9dPPAYpdbw5Fvx0QTLTV_EE3GDcudsTYMMRDGZFTK87t4X3Nn3FveNnOwzac8mDjOXab8JGSbQNfXwyn475Smvl2oprldezk38t8AAAD__0c_-Ck">