There’s no such law and the tradition isn’t ancient;
http://en.wikipedia.org/wiki/HMS_Birkenhead_%281845%29
Although the Birkenhead Drill is not ancient, I suspect the tradition pre-dated it (certainly in Western/Christian civilization). Otherwise the sailors/soldiers would not have accepted it as readily as they did.