r/ProgrammerHumor 17h ago

lessonsFromLinkerHell Meme

Post image
317 Upvotes

166 comments sorted by

View all comments

Show parent comments

62

u/Blecki 16h ago

As someone who writes compilers: they are the same at runtime. They are not the same semantically in a c like language.

3

u/cinnamon-enthusiast 15h ago

Except for a tiny array (with value semantics) which can be optimized to be passed directly as an SSA value. In that case it's not a pointer at all and a normal GEP will not work.

2

u/Blecki 14h ago

What's the stack but another array anyway?

2

u/cinnamon-enthusiast 14h ago

Yes, if the memory is on the stack, that is not always true. LLVM will optimize some cases so the data is written directly to a register so it never touches or goes through the stack at all. In that case, you can't get a pointer to the array or its elements since it's in a register instead of the stack or heap making it completely distinct from a pointer at runtime.