Once the NPC dies all bets are off. ->X may do nothing and print an error message to allegro.log, or it may point to a different random enemy entirely.
EDIT: More specifically, here is how enemy pointers work:
Under the old system, an enemy pointer was simply an integer which was interpreted as an index into the screen's enemy sprite list. Thus setting an npc variable, say foo, to 2 (not possible in ZScript, but can be done in assembly), then dereferencing it, would instruct ZC to find the third enemy currently on the screen. Which enemy is the third on screen varies frame to frame depending on what enemies have been created by scripts, killed by Link, entered from the side, split from a Tribble, etc.
A while back, to fix some bug (Gleeok heads and boomerangs, I think), I added to every sprite in the game a unique sprite ID. These IDs come from a common bank and are recycled as sprites are created/destroyed, but are constant throughout the lifetime of the sprite. Under the new system, an enemy pointer is this unique ID. Dereferencing the pointer asks ZC to search all enemies in the enemy sprite list for an enemy with that ID.
If the enemy has died recently, there are two scenarios - if a new enemy has also been created which has recycled the dead enemy's ID, the pointer will happily point to this new enemy. Otherwise, ZC can't find any such enemy in the enemy sprite list and throws an error.
It would be useful to know when a pointer has gone bad; I could add a way of testing for NULL, or something like that, to ZScript, but first there is the technical problem of recycled IDs.
The problem is that without recycling, once enough sprites have been created/destroyed on a single screen to overflow the maximum representable integer, IDs will no longer be unique, leading to strange behavior and possibly crashing.
Recycling causes other problems as well, though. Create a room with a single goriya, and write a script which creates a new goriya at a random location whenever the NPC count reaches 0. Then play the quest, and kill the goriya after it throws its boomerang. The boomerang will return to the newly-created goriya; the new enemy has recycled the old's ID.