The problem is not in gcc, because VC++ release compile also has the same bug: monsters just go somewhere and get stuck in walls. It could be uninitialized variable, because debug and release versions might have different values for them. I think I have to double check the routines that take direction as parameter, because some functions assume that it's a valid direction and nothing else.
Then there was a bug with endianess of wst file (my tile editor's native format). For some weird reason it's reversed in release version vs. debug version of VC++. I have no idea why. Anyway, I don't want to do anything more today. I wanted to release the game today, but this difference with release version was an unpleasant surprise.