Yes it compiles but it crashes when run. You forgot that buffer is pointer, meaning that you can say:
buffer:=@buffer[0]
When you do ptr:=@buffer, it means ptr:=@@buffer[0]
further on you do FillChar(ptr^,10,0); , which does:
FillChar((@@buffer[0])^,10,0);
= FillChar(@buffer[0],10,0);
So what you are filling is address of the data, not data itself.
Also saying pointer(buffer) is a typecast, and means different than @buffer, it didn't compile when i tried simply ptr:=buffer, which is what we are after.