"Considering the sheer volume of people who fly every day and the growing number of elderly people who fly, I'm surprised it doesn't actually happen more often," commercial airline pilot Patrick Smith told Business Insider.

How the crew reacts to the situation and the procedures they follow vary based on the events leading up to the death. Policies can also vary by company.

"Protocols vary airline to airline," Smith said. "Decisions such as whether the flight should divert are handled on a case-to-case basis."

Generally, the flight crew and ground control will work together to come up with a plan of action that's tailored to each specific situation.

According to Smith, author of the book "Cockpit Confidential," some of the factors that can affect whether a flight diverts include the location of the flight, the events leading up to the passenger's death — i.e., whether there was a medical emergency — and what options are available to the crew.

In cases where there is a medical emergency, some airlines allow flight attendants to communicate directly with medical professionals on the ground while others require ground communication to run through the pilots.

Once the passenger is determined to have died, the cabin crew will first work to store the body in a respectful manner and, if possible, away from other passengers. If there is room, the body will likely be placed in unoccupied rows of seats or in first class where there is more empty space.

Some airlines allow their cabin crews to cover and place the deceased passenger on the floor of the galley at the back of the plane.

But on crowded flights, there may not be room to relocate the deceased, at which point the corpse would be covered up and strapped into a seat.

At the time of the A340-500's launch, an airline representative told the Guardian's Andrew Clark that the compartment allows the crew to store a deceased passenger in a dignified manner and would be deployed only if an empty row of seats were not available.

Singapore Airlines retired its A340-500 fleet in 2013. It is unclear if any of the airline's other aircraft are equipped with this compartment.