<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54467>54467</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Friended struct's template alias is unable to access class's private member
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
SteveZhangSZ
</td>
</tr>
</table>
<pre>
```
struct theFriend{
template<class T>
using theAlias = decltype(&T::i);
};
class theC{
int i;
public:
friend struct theFriend;
};
int main(){
(void)sizeof(theFriend::theAlias<theC>);
}
```
```theFriend``` is a friend of ```theC```, but its template alias, when provided with ```theC```, produces a compile-time error:
```
<source>:3:35: error: 'i' is a private member of 'theC'
using theAlias = decltype(&T::i);
^
<source>:11:29: note: in instantiation of template type alias 'theAlias' requested here
(void)sizeof(theFriend::theAlias<theC>);
^
<source>:6:9: note: implicitly declared private here
int i;
^
1 error generated.
Compiler returned: 1
```
GCC and MSVC compile the code without problems. [Godbolt link](https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXACx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGIAMwAHKSuADJ4DJgAcj4ARpjEElykAA6oCoRODB7evgHBaRmOAuGRMSzxiVzJdpgOWUIETMQEOT5%2BQbaY9sUMjc0EpdFxCUm2TS1teZ0KE4MRwxWj1QCUtqhexMjsHLPEXg4A1AQImABixHiuJgDsVhoAgofPx5gsKQYEmCb%2BbsgGCgUhwAKj9sCZHi9Dl4MkZjqcHrQ8EwgT8ACKHLD/AgATxSmAg5gAbMCQCA8CsfvcHrc0VSIQ9/iigSdMG5btSoRECIc8PTIS8Ul5YkjkCAGVCqJdXIc9gceayLlcGOh%2BTSbnT/NTuYcWEwIhBKXcJS8IAA3VB4dArDIAL0wqCoEEV0pVZNZiOR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