<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62076>62076</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed Empty Base Optimisation with specific template configuration
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Abstract-Everything
</td>
</tr>
</table>
<pre>
The snippet below fails to compile on gcc and clang, it however, succeeds on MSVC ([godbolt link](https://godbolt.org/z/874f3xWEW)). Considering the [Empty Base Optimisation](https://en.cppreference.com/w/cpp/language/ebo) it feels like this should successfully compile. Is this a missed optimisation or is there a reason that templating the class disallows it?
Copy of the godbolt snippet for quick reference.
```
#include <type_traits>
class Empty {};
template <typename T, bool = std::is_class_v<T>>
class Base;
template <typename T>
class Base<T, true> : T {};
template <typename T>
class Base<T, false> {
T m_t;
};
template <typename T>
class Wrapper : Empty, Base<T> {
public:
explicit Wrapper() { static_assert(sizeof(*this) == sizeof(T)); }
};
template <typename T>
class Container {
Wrapper<T> m_t;
};
int main() { Wrapper<Container<int>> instance; }
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE1v4zgP_jXKhWjgSEkTH3zIRwO8h8F72GB7LGSZjrmVJa9It5P59QvbSZsdzCz2AwhiGH74fJASLTOdA2KhVju1OsxsL01MxbZkSdbJw9Mbpos0FM6zMlaX4tQgcKCuQ4ESfXyH2pJnkAguth15hBjg7BzYUIHzNpyV3gMJNPEd3zANb9w7h1jxAP3yy697UHqjVrtzrMroBTyFV7U6KL1pRDpWZqv0Uenj9fs8prPSx29KHzfrZW2-Pj89K50rnc9hHwNThYnCGaRBUKvdU9vJBXaWEf7fCbXEViiGHwlgmLuuS1hjwuBw7mKr9PFd6aPrOqWPQ5rennGAllHpfMhVI3oGT68I0hADN7H31ZSRue69v9xaM4f_8QSy0BIzVhDvLEFMQAMAE4KFhJZjAGmsgGDbeSu3WM5bZqiIrffxnYFEmaPKDirbTv_72F0g1iP41tbb2OqY4Pee3Ct8Jr3WPmbX3_SqDQXn-wpBmb1cOnyRZElYmad7scnN1Ge13qn1QZndPeDq_oMm2BbhNJyEMkYPyhyApRrGYLbELyPfy5sy-9OgdBObZIZB_j36H9XtR1VJPSrzBMps4fSPLP-cs7aeJ9L1lQgA4ATti3xS_zuZ52S7DtNod-zyoPeh_Z1k15ee3NDLDxP4tfPkSG5Ew23T-VAFLFbIvVhmTKL0hukbxnoEbIeDOuLMYZzQ7dNpumzK7GAI9F-S7WMQS2HIdt-1m89rvL9uIQWB1lK4S_VZ_yGgzJ6CTMcJKLDY4PDPEW6Hf1YVpspNbmdYLB43C71c6dVi1hR2nelFjtqZTVbnjzY3NWJernTm9MYYnFGhM22y5WKhM7NcLOYbu6ndGrHO8hoXVaWWGbaW_Nz7t3bYYzNi7rF41Nn6ceZtiZ5vmzgVA-ih7M-slpknFv4sExKPxZdph_xkw8E7SQPcoaOaHHwMxMVQ07lPI2jWJ198t2ZJmr68Lr9B8fp46FL8DZ0ofRxds9LH0fgfAQAA__8KwPAh">