<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/119705>119705</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Wrong named address space for anonymous struct
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ubizjak
</td>
</tr>
</table>
<pre>
The following code when compiled with clang-19 (-O2):
```
struct s
{
struct
{
int a;
int b;
} __seg_gs *c;
int d;
};
struct s n;
void __seg_gs *t2 (void)
{
return n.c;
}
```
errors out with:
```_.c:34:10: error: returning 'struct (unnamed struct at segstr.c:22:3) *' from a function with result type '__attribute__((address_space(256))) void *' changes address space of pointer```.
The error is wrong, as the ```c``` member should be put into __seg_gs named address space. Equivalent code with named struct:
```
struct _r
{
int a;
int b;
};
struct r
{
struct _r __seg_gs *c;
int d;
};
struct r m;
void __seg_gs *t1 (void)
{
return m.c;
}
```
compiles OK.
GCC-14.2.1 is able to compile both testcases to the expected (the same) code.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyclM2OozgQx5_GXEpBuEhCOHBgujd72MNcVtojMqYAzxo764_O9j79yoROd2taOYxkCVeZ-lMfPyy8V5MhatjhGzs8ZyKG2bom9uq_H-LvrLfDa_PnTDBare1VmQmkHQiuMxmQdrkoTQNcVZhBamGmHa-B4Wn3HRnWrGxZsa5jsa2i9cFFGcAnd_WNFS3AzbVu31wAygQQrPxo9m8mq56h6zxN3eSBYSvfDtJbw81g1fO2ef8mmLvrxarhk0bAlHhyp8zvyTkK0RkwuXyX_VwQK1pyzjoPNoa1FT_X3aXwttyzsuUFK1tYI9Lmpp_6yrDa8mR4isaIhYatNSACeJp8cKsOYhJjmFrdMqxgdHYBAWM0MihrbvNw5KMOEF4vlLS7ToTgVB8DdR3DE8OTGAZH3nf-IiQxPOHhmGpfF6wN2vTlLMxEHrYAWAPAjnCxygRy9zrzW90JmLVCUB6uzpqJ4RMID2EmuL8s7ztYaOnJgZ9t1AP0BJcY0jDt-4hu_fiUQQ6__RPVi9BkwoZlKvxj5x4h2LkPDH7C7QNsX2DkfkIXOvcrPDpYHvDIH_G4PORx-zE9fP9jm8jvT087vs8x52kkotcEwb79wNDbMEMgH6Tw5NNJGhT9eyEZKFFwSrYXCyUyUqc3WYDbMxuacqjLWmTU8KrcFxzrqsrmBgtZ1kNJvZDj6VgVBz6W9amuh8N4HEbkmWqwwD1HjnzPj_yY8_JYioOsjgNVeEBk-4IWoXSu9cuSWzdlyvtIDed1VRwyLXrSfr29EA1dYT1liOkyc00K2vVx8mxfaOWDf5cJKmhq_kp0fgUXjNaBMNa8Ljb6bdBZdLqZQ7j4BBaeGZ4nFebY59IuDM9JfHvsLs7-IBkYnteUPMPzlvNLg_8HAAD__x6Joys">