Storing data in pointers
muxup.com
Storing data in pointers
1–10 of 71 posts
Re: Storing data in pointers
#2But if you aren't writing a compiler or an embedded system, you should never do this.
Re: Storing data in pointers
#3I don't want to say you should never do this. But if you aren't writing a compiler or an embedded system, you should never do this.
Re: Storing data in pointers
#4I don't want to say you should never do this. But if you aren't writing a compiler or an embedded system, you should never do this.
It is also very useful for some lockfree algorithms, e.g. to fit a pointer and a sequence number within a 64-bit value.
Re: Storing data in pointers
#5Re: Storing data in pointers
#6Re: Storing data in pointers
#7I don't want to say you should never do this. But if you aren't writing a compiler or an embedded system, you should never do this.
Re: Storing data in pointers
#8There is also the inverse use case: smuggling pointers inside status codes, enums, and similar. For example, optionally encoding a pointer to additional error metadata for non-zero result codes. In C++ it isn’t that uncommon to also see Result types implemented similarly when the type allows it.