<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57999>57999</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missing field type index for union nested in struct
</td>
</tr>
<tr>
<th>Labels</th>
<td>
debuginfo,
platform:windows
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ZequanWu
</td>
</tr>
</table>
<pre>
Example:
```
$ cat a.cpp
struct S {
union U {
long l;
short s;
int i;
};
};
S s;
int main() {
return 0;
}
$ clang-cl /Z7 /c a.cpp /Foa.obj && lld-link /out:a.exe /debug /nodefaultlib /entry:main a.obj
$ llvm-pdbutil dump a.pdb --types
Types (TPI Stream)
============================================================
Showing 5 records
0x1000 | LF_ARGLIST [size = 8]
0x1001 | LF_PROCEDURE [size = 16]
return type = 0x0074 (int), # args = 0, param list = 0x1000
calling conv = cdecl, options = None
0x1002 | LF_UNION [size = 32] `S::U`
unique name: `.?ATU@S@@`
field list: <no type>
options: forward ref (= 0x1002) | has unique name | is nested, sizeof 0
0x1003 | LF_FIELDLIST [size = 16]
- LF_NESTTYPE [name = `U`, parent = 0x1002]
0x1004 | LF_STRUCTURE [size = 32] `S`
unique name: `.?AUS@@`
vtable: <no type>, base list: <no type>, field list: 0x1003
options: contains nested class | has unique name, sizeof 1
$ cl /Z7 b.cpp /Feb.exe /link /nodefaultlib /entry:main /debug
$ llvm-pdbutil dump a.pdb --types
Types (TPI Stream)
============================================================
Showing 7 records
0x1000 | LF_ARGLIST [size = 8]
0x1001 | LF_PROCEDURE [size = 16]
return type = 0x0074 (int), # args = 0, param list = 0x1000
calling conv = cdecl, options = None
0x1002 | LF_UNION [size = 32] `S::U`
unique name: `.?ATU@S@@`
field list: <no type>
options: forward ref (-> 0x1006) | has unique name | is nested, sizeof 0
0x1003 | LF_FIELDLIST [size = 16]
- LF_NESTTYPE [name = `U`, parent = 0x1002]
0x1004 | LF_STRUCTURE [size = 32] `S`
unique name: `.?AUS@@`
vtable: <no type>, base list: <no type>, field list: 0x1003
options: contains nested class | has unique name, sizeof 1
0x1005 | LF_FIELDLIST [size = 40]
- LF_MEMBER [name = `l`, Type = 0x0012 (long), offset = 0, attrs = public]
- LF_MEMBER [name = `s`, Type = 0x0011 (short), offset = 0, attrs = public]
- LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1006 | LF_UNION [size = 32] `S::U`
unique name: `.?ATU@S@@`
field list: 0x1005
options: has unique name | is nested | sealed, sizeof 4
```
If we make the union an anonymous union by removing its name, clang generated pdb is the following:
```
Types (TPI Stream)
============================================================
Showing 8 records
0x1000 | LF_ARGLIST [size = 8]
0x1001 | LF_PROCEDURE [size = 16]
return type = 0x0074 (int), # args = 0, param list = 0x1000
calling conv = cdecl, options = None
0x1002 | LF_STRUCTURE [size = 32] `S`
unique name: `.?AUS@@`
vtable: <no type>, base list: <no type>, field list: <no type>
options: forward ref (-> 0x1005) | has unique name, sizeof 0
0x1003 | LF_UNION [size = 60] `S::<unnamed-tag>`
unique name: `.?AT<unnamed-type-$S1>@S@@`
field list: <no type>
options: forward ref (= 0x1003) | has unique name | is nested, sizeof 0
0x1004 | LF_FIELDLIST [size = 52]
- LF_MEMBER [name = `l`, Type = 0x0012 (long), offset = 0, attrs = public]
- LF_MEMBER [name = `s`, Type = 0x0011 (short), offset = 0, attrs = public]
- LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
- LF_NESTTYPE [name = ``, parent = 0x1003]
0x1005 | LF_STRUCTURE [size = 32] `S`
unique name: `.?AUS@@`
vtable: <no type>, base list: <no type>, field list: 0x1004
options: contains nested class | has unique name, sizeof 4
0x1006 | LF_FIELDLIST [size = 40]
- LF_MEMBER [name = `l`, Type = 0x0012 (long), offset = 0, attrs = public]
- LF_MEMBER [name = `s`, Type = 0x0011 (short), offset = 0, attrs = public]
- LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1007 | LF_UNION [size = 60] `S::<unnamed-tag>`
unique name: `.?AT<unnamed-type-$S1>@S@@`
field list: 0x1006
options: has unique name | is nested | sealed, sizeof 4
```
msvc generated pdb:
```
Types (TPI Stream)
============================================================
Showing 4 records
0x1000 | LF_ARGLIST [size = 8]
0x1001 | LF_PROCEDURE [size = 16]
return type = 0x0074 (int), # args = 0, param list = 0x1000
calling conv = cdecl, options = None
0x1002 | LF_FIELDLIST [size = 40]
- LF_MEMBER [name = `l`, Type = 0x0012 (long), offset = 0, attrs = public]
- LF_MEMBER [name = `s`, Type = 0x0011 (short), offset = 0, attrs = public]
- LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1003 | LF_STRUCTURE [size = 32] `S`
unique name: `.?AUS@@`
vtable: <no type>, base list: <no type>, field list: 0x1002
options: has unique name, sizeof 4
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWVtvozgU_jXkxUoEBnJ54KHNZVWp7VRNotXOy8qASTxjbAabtN1fv8dAUmguM9XMdqdVIqvx_dy_c5yGMn4Kpo8kzTi13AvLnlj2hdW361YNsYciohHpRVlWTSmdF5FGc2QNLqsZhArBpEDL5hRCXIoV4pbbmFJrmWukWnNMaMQaM9Zgshs1-_PGOXMmJUxYeGjhUZNsTnWRC2S3rngWhROx6kYcWXj2eWD-RpVopjuTpCfDL9DtQ0Ocx13OxFezJAsNGiI9-kjNMKZhsTIdIWOakIJrzkIzpkLnT7DT8IbK255pc75Ju1kcFppxFBdpBhtgiLpd_ZRR9ayQvc_CrMP1w8XdFZrrnJIUpK5vdifvr9WiztfygYGP-GC1SObxTgf2o2PbNph1jK5nf1_c_3F9NV8gy79U7B8wgDtBQ8uftHY7291395_G08nyftra7_QbB3af2lmM_std9qNtDzyjaXAwo2I8hoGLSL5S1QYzk5GcpIgzpetDhtm9uyPCuREukmJT7otiGnFzXmYaoqW68FYK2pIDb-VY3l59um3J4GKQAUFozk20uhfLXZQ2yEIkfisoE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