I wrote a little blog post on storing data in pointers - initially motivated by documenting the impact of >48-bit virtual addresses on such tricks and the various available hardware pointer masking schemes https://muxup.com/2023q4/storing-data-in-pointers Any corrections or additional notes, do let me know!
Storing data in pointers

Some notes on storing data in pointers and the impact of >48-bit virtual addresses

Muxup

@asb Nice explanation and overview of examples! Thank you for sharing.

Since you asked for more examples: Øyvind Kolås has experimented with using the least significant bit trick for string interning of ultra-short strings in the pointer to the string itself. He describes his findings here: https://squoze.org/

squoze - unicode encodings for pointers and hashes

@vanderZwan I probably can't mention all the cases using LSB for a space efficient tagged union, but but this is a nice one and I didn't do a great job of highlighting Objective-C's similar optimisation - so I've added this one in. Cheers!