You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove extra indirection from statics with linkage? #156468
Note that this replacement isn't possible for functions, only statics (since &raw const fn doesn't work). Otherwise, yeah, I agree that the added level of indirection is unneeded (and personally, not something I'd want to use).
Targets where function pointers are larger than data pointers would be an issue, but the (unstable) std::marker::FnPtr::addr method would truncate on those targets too.
Activity
chorman0773 commentedon May 12, 2026
Note that this replacement isn't possible for functions, only statics (since
&raw const fndoesn't work). Otherwise, yeah, I agree that the added level of indirection is unneeded (and personally, not something I'd want to use).RalfJung commentedon May 12, 2026
As @bjorn3 mentioned on Zulip, it's possible, just awkward: you'd do something like
bjorn3 commentedon May 12, 2026
Targets where function pointers are larger than data pointers would be an issue, but the (unstable)
std::marker::FnPtr::addrmethod would truncate on those targets too.chorman0773 commentedon May 12, 2026
That also loses the ability to use the definition safely.