Ive worked on embedded systems where stuff like that would be a problem, howver I also knew the memory map for my target.
I wanted to make some crypto run faster so i used memcpy on a pointer to a function to copy executable code from slow flash to fast ram.