frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Pointer Tagging in C++: The Art of Packing Bits into a Pointer

https://vectrx.substack.com/p/pointer-tagging-in-c-the-art-of-packing
16•signa11•3h ago

Comments

jandrewrogers•1h ago
As someone that uses pointer tagging, I must point out that this article is insufficiently defensive.

I've done my own exploration of what I can get away with across 64-bit x86 and ARM in this regard. It has been a while but the maximum number of bits that are reliably taggable across all environments and use cases that I have been able to determine is six. Can you get away with more? Probably yes, but there are identifiable environments where it will explode if you do so. That may not apply to your use case.

Reliable pointer tagging is not trivial.

forrestthewoods•1h ago
Can you share details? What modern platforms/environments does this not work on? Are you saying the intersection of available bits on all platforms is just 6? Or are there platforms that actually use 58 bits?

Would be great to hear some actionable details.

nervoir•36m ago
If you include ARM then PAC and MTE will consume a few of those precious bits. Don’t think any platforms use PAC for pointers to allocated objects though unless they’re determined to be exceptionally important like creds structure pointers in task structures in the kernel.
jandrewrogers•1m ago
It wasn’t anything clever. A couple years ago I did a dive into x86 and ARM literature to determine what bits of a pointer were in use in various environments or were on a roadmap to be used in the future. To be honest, it was more bits than I was expecting.

Note also that this is the intersection of bits that are available on both ARM and x86. If you want it to be portable, you need both architectures. Just because ARM64 doesn’t use a bit doesn’t mean that x86 doesn’t and vice versa.

Both x86 and ARM have proposed standards for pointer tagging in the high bits. However, those bits don’t perfectly overlap. Also, some platforms don’t fully conform to this reservation of high bits for pointer tagging, so there is a backward compatibility issue.

Across all of that, I found six high bits that were guaranteed to be safe for all current and future platforms. In practice you can probably use more but there is a portability risk.

sema4hacker•1h ago
In the 70's when memory was always small and expensive, I had to keep things as packed and tight as possible. But now memory is so huge and cheap that it's been a long time since I had to worry about things like packing bits, which is incredibly bug-prone anyway.
dh2022•1h ago
A benefit for packing pointers is when the data needed is already packed-this will avoid a pointer reference.
gblargg•1h ago
What's old is new again. The original 68000 processor only had a 24-bit physical address bus, so the MacOS used the upper 8 bits for tag information, and didn't even need to clear it when accessing. Once they started using CPUs and more RAM that needed these upper bits, they had to make "32-bit clean" versions of programs.

I wonder whether you could use the MMU to ignore these upper bits, by mapping each combination of bits to the same address as with them clear.

mlhpdx•23m ago
Brings back memories. I cut my teeth in C++ working on a system that used pointer tagging and transactional memory. Good times. That mind mending experience perhaps made my career.
fooker•21m ago
This sort of stuff is starting to have hardware support now, so you no longer have to perform this wizardry.

Enabled on most iphones even!

Privacy and Security Risks in the eSIM Ecosystem [pdf]

https://www.usenix.org/system/files/usenixsecurity25-motallebighomi.pdf
18•walterbell•1h ago•0 comments

DSM Disorders Disappear in Statistical Clustering of Psychiatric Symptoms (2024)

https://www.psychiatrymargins.com/p/traditional-dsm-disorders-dissolve?r=2wyot6&triedRedirect=true
78•rendx•3h ago•18 comments

The US Is Tracking 14 Potential Rabies Outbreaks in 20 States

https://www.accuweather.com/en/health-wellness/the-us-is-tracking-14-potential-rabies-outbreaks-i...
63•treasure2seek•1h ago•24 comments

Sj.h: A tiny little JSON parsing library in ~150 lines of C99

https://github.com/rxi/sj.h
366•simonpure•12h ago•179 comments

Why is Venus hell and Earth an Eden?

https://www.quantamagazine.org/why-is-venus-hell-and-earth-an-eden-20250915/
90•pseudolus•6h ago•114 comments

Simulating a Machine from the 80s

https://rmazur.io/blog/fahivets.html
10•roman-mazur•3d ago•0 comments

South Korea's President says US investment demands would spark financial crisis

https://www.cnbc.com/2025/09/21/south-koreas-president-lee-trump-investment-financial-crisis.html
108•donsupreme•3h ago•69 comments

Lightweight, highly accurate line and paragraph detection

https://arxiv.org/abs/2203.09638
92•colonCapitalDee•8h ago•11 comments

How I, a beginner developer, read the tutorial you, a developer, wrote for me

https://anniemueller.com/posts/how-i-a-non-developer-read-the-tutorial-you-a-developer-wrote-for-...
138•wonger_•4h ago•69 comments

40k-Year-Old Symbols in Caves Worldwide May Be the Earliest Written Language

https://www.openculture.com/2025/09/40000-year-old-symbols-found-in-caves-worldwide-may-be-the-ea...
129•mdp2021•3d ago•75 comments

Obsidian Note Codes

https://ezhik.jp/obsidian/note-codes/
58•surprisetalk•3d ago•8 comments

Pointer Tagging in C++: The Art of Packing Bits into a Pointer

https://vectrx.substack.com/p/pointer-tagging-in-c-the-art-of-packing
16•signa11•3h ago•9 comments

DXGI debugging: Microsoft put me on a list

https://slugcat.systems/post/25-09-21-dxgi-debugging-microsoft-put-me-on-a-list/
241•todsacerdoti•14h ago•70 comments

How can I influence others without manipulating them?

https://andiroberts.com/leadership-questions/how-to-influence-others-without-manipulating
72•kiyanwang•7h ago•46 comments

Calculator Forensics (2002)

https://www.rskey.org/~mwsebastian/miscprj/results.htm
76•ColinWright•3d ago•32 comments

My new Git utility `what-changed-twice` needs a new name

https://blog.plover.com/2025/09/21/#what-changed-twice
59•jamesbowman•7h ago•26 comments

Why your outdoorsy friend suddenly has a gummy bear power bank

https://www.theverge.com/tech/781387/backpacking-ultralight-haribo-power-bank
196•arnon•17h ago•235 comments

Show HN: I wrote an OS in 1000 lines of Zig

https://github.com/botirk38/OS-1000-lines-zig
137•botirk•3d ago•19 comments

Procedural Island Generation (VI)

https://brashandplucky.com/2025/09/28/procedural-island-generation-vi.html
46•ibobev•8h ago•3 comments

I forced myself to spend a week in Instagram instead of Xcode

https://www.pixelpusher.club/p/i-forced-myself-to-spend-a-week-in
217•wallflower•15h ago•80 comments

RCA VideoDisc's Legacy: Scanning Capacitance Microscope

https://spectrum.ieee.org/rca-videodisc
11•WaitWaitWha•3d ago•1 comments

Show HN: Tips to stay safe from NPM supply chain attacks

https://github.com/bodadotsh/npm-security-best-practices
34•bodash•8h ago•16 comments

Timesketch: Collaborative forensic timeline analysis

https://github.com/google/timesketch
110•apachepig•12h ago•10 comments

Node 20 will be deprecated on GitHub Actions runners

https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
87•redbell•1d ago•28 comments

Show HN: Wan-Animate – Unified Character Animation and Replacement

https://www.wananimate.net/
11•laiwuchiyuan•4h ago•0 comments

How Isaac Newton discovered the binomial power series (2022)

https://www.quantamagazine.org/how-isaac-newton-discovered-the-binomial-power-series-20220831/
61•FromTheArchives•3d ago•11 comments

INapGPU: Text-mode graphics card, using only TTL gates

https://github.com/Leoneq/iNapGPU
53•userbinator•4d ago•6 comments

Seattle, Tech Boomtown, Grapples with a Future of Fewer Tech Jobs

https://www.wsj.com/tech/seattle-tech-amazon-microsoft-jobs-95f2db27
32•mooreds•3h ago•5 comments

Unified Line and Paragraph Detection by Graph Convolutional Networks (2022)

https://arxiv.org/abs/2503.05136
87•Qision•15h ago•13 comments

Bringing Observability to Claude Code: OpenTelemetry in Action

https://signoz.io/blog/claude-code-monitoring-with-opentelemetry/
38•pranay01•11h ago•14 comments