frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)

https://thecloudlet.github.io/blog/project/emacs-03/
25•thecloudlet•3h ago

Comments

thecloudlet•3h ago
Emacs internal part 2 HN link:

https://news.ycombinator.com/item?id=47259961

tialaramex•1h ago
It's not clear to me (and as an unsafe language it's not called out by your compiler if you do something illegal) what the correct way to spell this kind of trick is in C++

I had thought you need the pointer-sized integer types and mustn't do this directly to an actual pointer, but maybe I was wrong (in theory, obviously practice doesn't follow but that's a dangerous game)

db48x•1h ago
Do the way LLVM does it.
thecloudlet•1h ago
Doing bitwise operations directly on raw pointers is a fast track to Undefined Behavior in standard C/C++. Emacs gets away with it largely due to its age, its heavy reliance on specific GCC behaviors/extensions, and how its build system configures compiler optimizations.

In modern C++, the technically "correct" and safe way to spell this trick is exactly as you suggested: using uintptr_t (or intptr_t).

shadowgovt•52m ago
Is there a similar solution to doing this in Rust? I suppose inside `unsafe` you can do basically anything.
thecloudlet•32m ago
Waiting for Rust experts.
simonask•23m ago
Rust is basically in the same place as C++, i.e. provenance rules are currently ad-hoc/conventional, meaning that pointer tagging is a grey area.
tialaramex•15m ago
Nope. Rust stabilized strict provenance over a year ago. Some details about aliasing aren't tied down, but so long as you can obey the strict provenance rules you're golden today in Rust to hide flags in pointers etc.

https://blog.rust-lang.org/2025/01/09/Rust-1.84.0/#strict-pr...

tialaramex•17m ago
Unlike C++ all of Rust's primitive types get the same first class treatment as your user defined types and so the appropriate API is provided as methods on pointer types. For this you want ptr::map_addr which takes a callable (such as your own function for this mapping or a lambda) to fiddle with the pointer.

https://doc.rust-lang.org/std/primitive.pointer.html#method....

Rust's MIRI is able to run code which uses this (a strict provenance API) because although MIRI's pointers are some mysterious internal type, it can track that we mapped them to hide our tags, and then later mapped back from the tagged point to recover our "real" pointer and see that's fine.

This isn't an unsafe operation. Dereferencing a pointer is unsafe, but twiddling the bits is fine, it just means whoever writes the unsafe dereferencing part of your codebase needs to be very careful about these pointers e.g. making sure the ones you've smuggled a tag in aren't dereferenced 'cos that's Undefined Behaviour.

It's clear to me how this works in Rust, it's just unclear still in C++

trws•35m ago
There’s a paper in flight to add a stdlib type to handle pointer tagging as well while preserving pointer provenance and so-forth. It’s currently best to use the intptr types, but the goal is to make it so that an implementation can provide specializations based on what bits of a pointer are insignificant, or even ignored, on a given target without user code having to be specialized. Not sure where it has landed since discussion in SG1 but seemed like a good idea.
tialaramex•7m ago
Given you aren't sure since SG1 this might be useless but... do you have a paper number? Or, more likely, know an author's name ?

US- and Greek-owned tankers ablaze after Iran claims 'underwater drone' strike

https://www.lloydslist.com/LL1156592/US--and-Greek-owned-tankers-ablaze-after-Iran-claims-underwa...
81•everybodyknows•26m ago•39 comments

Malus – Clean Room as a Service

https://malus.sh
205•microflash•2h ago•67 comments

US banks' exposure to private credit hits $300B (2025)

https://alternativecreditinvestor.com/2025/10/22/us-banks-exposure-to-private-credit-hits-300bn/
121•JumpCrisscross•3h ago•70 comments

Kotlin creator's new language: a formal way to talk to LLMs instead of English

https://codespeak.dev/
72•souvlakee•1h ago•50 comments

Dolphin Progress Release 2603

https://dolphin-emu.org/blog/2026/03/12/dolphin-progress-report-release-2603/
195•BitPirate•6h ago•24 comments

The purpose of Continuous Integration is to fail

https://blog.nix-ci.com/post/2026-02-05_the-purpose-of-ci-is-to-fail
42•Norfair•2d ago•38 comments

Avoiding Trigonometry (2013)

https://iquilezles.org/articles/noacos/
147•WithinReason•6h ago•32 comments

The Met Releases High-Def 3D Scans of 140 Famous Art Objects

https://www.openculture.com/2026/03/the-met-releases-high-definition-3d-scans-of-140-famous-art-o...
5•coloneltcb•15m ago•0 comments

Hive (YC S14) is hiring scrappy product managers and product/data engineers

https://jobs.ashbyhq.com/hive.co
1•patman_h•1h ago

3D-Knitting: The Ultimate Guide

https://www.oliver-charles.com/pages/3d-knitting
173•ChadNauseam•7h ago•60 comments

ATMs didn't kill bank Teller jobs, but the iPhone did

https://davidoks.blog/p/why-the-atm-didnt-kill-bank-teller
74•colinprince•1h ago•103 comments

Show HN: s@: decentralized social networking over static sites

http://satproto.org/
385•remywang•15h ago•180 comments

Asia rolls out 4-day weeks, WFH to solve fuel crisis caused by Iran war

https://fortune.com/2026/03/11/iran-war-fuel-crisis-asia-work-from-home-closed-schools-price-caps/
33•speckx•28m ago•4 comments

Show HN: We analyzed 1,573 Claude Code sessions to see how AI agents work

https://github.com/obsessiondb/rudel
83•keks0r•2h ago•47 comments

Big Data on the Cheapest MacBook

https://duckdb.org/2026/03/11/big-data-on-the-cheapest-macbook
216•bcye•4h ago•190 comments

Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)

https://thecloudlet.github.io/blog/project/emacs-03/
25•thecloudlet•3h ago•11 comments

Colon cancer now leading cause of cancer deaths under 50 in US

https://www.theguardian.com/us-news/2026/mar/12/colon-cancer-leading-deaths
19•stevenwoo•26m ago•1 comments

Suburban school district uses license plate readers to verify student residency

https://www.nbcchicago.com/consumer/suburban-school-district-uses-license-plate-readers-to-verify...
101•josephcsible•1h ago•107 comments

Printf-Tac-Toe

https://github.com/carlini/printf-tac-toe
87•carlos-menezes•4d ago•8 comments

Atlassian CEO: AI doesn't replace people here, but we're firing them anyway

https://www.heise.de/en/news/Atlassian-CEO-AI-doesn-t-replace-people-here-but-we-re-firing-them-a...
13•layer8•22m ago•1 comments

High fidelity font synthesis for CJK languages

https://github.com/kaonashi-tyc/zi2zi-JiT
24•kaonashi-tyc-01•3d ago•3 comments

Show HN: Axe A 12MB binary that replaces your AI framework

https://github.com/jrswab/axe
57•jrswab•2h ago•48 comments

SBCL: A Sanely-Bootstrappable Common Lisp (2008) [pdf]

https://research.gold.ac.uk/id/eprint/2336/1/sbcl.pdf
97•pabs3•9h ago•59 comments

SHOW HN: A usage circuit breaker for Cloudflare Workers

18•ethan_zhao•2d ago•7 comments

Reliable Software in the LLM Era

https://quint-lang.org/posts/llm_era
56•mempirate•7h ago•21 comments

Datahäxan

https://0dd.company/galleries/witches/7.html
108•akkartik•3d ago•9 comments

Returning to Rails in 2026

https://www.markround.com/blog/2026/03/05/returning-to-rails-in-2026/
274•stanislavb•9h ago•181 comments

Tested: How Many Times Can a DVD±RW Be Rewritten? Methodology and Results

https://goughlui.com/2026/03/07/tested-how-many-times-can-a-dvd%C2%B1rw-be-rewritten-part-2-metho...
208•giuliomagnifico•4d ago•69 comments

ArcaOS 5.1.2 (based on OS/2 Warp 4.52) now available

https://www.arcanoae.com/arcaos-5-1-2-now-available/
29•speckx•2h ago•11 comments

1B identity records exposed in ID verification data leak

https://www.aol.com/articles/1-billion-identity-records-exposed-152505381.html
166•robtherobber•6h ago•38 comments