<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/146956>146956</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`clang::Interpreter` cannot get the address of a static const member
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jeaye
</td>
</tr>
</table>
<pre>
This is easily reproducible via `clang-repl`, but the same issue exists for programmatic `clang::Interpreter` usage. @vgvassilev for vis.
```sh
# Unable to take the address of a static const member.
❯ clang-repl
clang-repl> struct foo{ static int const bar{ 5 }; };
clang-repl> int const *p{ &foo::bar };
clang-repl> #include <cstdio>
clang-repl> printf("%d\n", *p);
JIT session error: Symbols not found: [ _ZN3foo3barE ]
Segmentation fault (core dumped)
# Getting its value works fine.
❯ clang-repl
clang-repl> struct foo{ static int const bar{ 5 }; };
clang-repl> int const i{ foo::bar };
clang-repl> #include <cstdio>
clang-repl> printf("%d\n", i);
5
❯ clang-repl --version
LLVM (http://llvm.org/):
LLVM version 19.1.7
Optimized build.
```
I have verified this bug exists on versions:
* 19.1.7
* 20.1.5
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVE2PpDYQ_TXFpdTImDY0Bw7MR0cTbZLDbnLIJTK4oL1rbGQbksmvj0z3fEibRDllJSTjkt-revVUJUPQkyVqQdyBeMjkGi_Ot59JPlPWO_XcfrrogDogyaDNM3pavFProHtDuGmJULHBSDsdPC0GKgb8Hvs1YrwQBjkT6hBWQvpDhxhwdB4X7yYv51lGPbzCoeyg7J5sJL94iuShYrgGOVGOcGTbtKVSDW07xaZDDqxLX8WuX7ikGy_xZytTbdFhlF9or0Mq5SkEdCNKDHFPPDgbIs409-R3rkcOzQN0Z3wnh3XvLuUjhujXIeLoHNR3L0zaxhtbL32KC4T6Acq72_EVyxsAeLckBPAqce496KX_JyDwUtvBrIoQyvshRKUdlI9fvVu8tnEEfgLOgQsF4t7uv_fXjLy5sn__9AkDhaCdRfLeeSg7_Pg8984EtC4JXa1KQRB3-NuvP5ajc2Uv_SOCeADWfaRpJpva4CyOcjVJ0mlwnlCt80Iqpbr6xEv8jmLUdkIdA27SrIS_O_8l4KgtfTMLdHr-PzVfv3Ze3LryN4rxcNjIJ0-AdR8-_PJDauklxiVVyM_Az8Zsc-78tN-aFGYd4v70hsSiyYu83uM_LVHP-k9S2K_aqPz90FyreMKL3Chh9ahJYUwj36_Ty9A6-8Ibrsl2P7u3JOnCWV7kIlNtqZqykRm1RS0KUfNTccouLW8aIfiojkPP-5qaipW8LEStRnE6sVpmuuWMC1azkjPGCpaPw8DYaaiqSp54PdRwZDRLbfIX-dm-WdriWDWiyozsyYR9j3F-XSmcp5Xm2wQ49OsU4MhMUvRGEXU01P7rEhqkTaMwUfxPuyRbvWmTXeHVr0nHy9rng5tv5t2Ow-LdZxoi8PMuJQA_39RsLf8rAAD__8uouw4">