<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116047>116047</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assigning to an "extern" variable does not cause type information to be emitted
</td>
</tr>
<tr>
<th>Labels</th>
<td>
debuginfo
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
labath
</td>
</tr>
</table>
<pre>
```
$ clang -c -o - -x c++ -g - <<<"struct S {}; extern S *s; void f() {s = new S(); }" | llvm-dwarfdump - | grep DW_TAG_structure_type
$ clang -c -o - -x c++ -g - <<<"struct S {}; S *s; void f() {s = new S(); }" | llvm-dwarfdump - | grep DW_TAG_structure_type
0x00000033: DW_TAG_structure_type
```
I believe the first command should also produce debug info for `struct S`. We cannot rely on the type information to be emitted in the compilation unit defining `s` as it may not even have access to the definition (it could be treating it opaquely as a forward-declaration). Interestingly, not even `-fstandalone-debug` causes the type to be emitted.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VM2O8zYMfBr6QjiQJf9sDj4kG6T4zl-BPS5oiXZUyJYrydnN2xdytli0h_ZS1BBsgCCHMyPSFKOdFuYemjM0l4K2dPOhdzRQuhWDN48eWvF1xAXECWSN2tEyYamx9Fhi-Yka5BnkGcsJSwT1-nWkjClsOuFPhO4M3QXUGfkzcVhySJ5iDty9NTiCfAF5zHkRQV1w4Q_8-QzmpFwsJUL3is7d59J8UBjNNq-5YfeKU-AVL2_vv55-eX823QK_p8fK_xHt_5mv-BT7oxSo0z8K-9v17O8fOLCzfGdMN8bRhphQ-3mmxWC8-c0ZJBc9rsGbTTMaHrYJ7TJ6HH1AaMWfDkArDvjGqGlZfMLA7oF-2WEzh70mzJRsDnocGHm2KbFB-8zSfl6teyZsi01oeLSLXaa9C7QCKaJNONMDcwe-84I3ujOS1hxjRs04z7IdBuSLzXqyjIExBaaUAW1Cv9LvW-ZIESlr-aBgSsPaUdg5gDwe8MeSOHDMRe4B8vW7MbSiHGOixZDzC5e7MZmkpi1y_Nb9F62HwvTKHNWRCu6rTlWNaERTF7deVI1QuuskNbKuzag6PVA36soMZmzGprC9FLKuqkpVSnVKHFp5bIe2Vi-Cj1R3A9SCZ7LukMfo4MNU2Bg37quqFXVXOBrYxX19pdzZ5hsBKfM2h36fvWGbItTC2ZjiN0yyyXF_2n8A2b3kkbK38rmgeXrvFCwNjtF4jrtJuw3_cvPFFlx_S2mNoE4gryCvk023bThoP4O8ZgZfn3IN_jfWCeR1VxVBXr-E3Xv5RwAAAP___5Jymw">