What could possibly go wrong with casting a pointer to an integer and using that as the identifier of the object being pointed to?

Reply to this note

Please Login to reply.

Discussion

Your computer, your rules.

Commonly done when abstracting resource handles across GPU APIs

Why even cast it to an integer? Can't you directly use a pointer as an identifier?

That’s my take

Strongly typed language shenanigans, I suppose.

Potential overflow and point to wrong spot

Can ask the question in small brain language instead?

What could go wrong, using a pointer to a web page as your social web identity?

Answer: Indieweb, Mastodon, verifiable claims and other silos.

I would worry about collisions. The object with the id could livee longer than then pointer. When the memmory is free again we might have a new different object at the same point in memmory...

Thank you for this answer.

The possibility of collision is very high. You should use an uuid

harder to test?

It's a great idea. In fact, when other people load the object they should put it into the same memory location. We need to keep everybody in sync.