Official manufacturers safety sheet
There seems to be a lot of urban legends about hot cutting foam. Here's the skinny from official safety sheets.
DOW (blue foam):
Based on combustion toxicity testing, the products of combustion from this foam are not more
acutely toxic than the products of combustion from common building materials such as wood.
Fumes or vapor released during thermal operations such as hot-wire cutting of STYROFOAM
Brand products may cause eye and respiratory irritation.
Dust or solid particles of STYROFOAM Brand insulation products may cause eye irritation or corneal
injury due to mechanical action, as with any other solid particulate that may contact the eye.
The dust may also cause irritation to the upper respiratory tract.
Owens Corning (pink foam):
Avoid dust formation.
Do not breathe dust. Wear personal protective equipment.
Dust collection system must be used in cutting or machining or other dust generating processes, such as using power tools.
Vacuum or wet clean-up methods should be used.
Grinding, cutting, sawing or fabrication activities that cut large numbers of interior foam cells can
release localized amounts of flammable residual blowing agent or release dust particles that under
certain conditions may ignite or form explosive dust atmospheres.
Dusts may cause mechanical irritation to eyes and skin. Ingestion may cause transient irritation of
throat, stomach and gastrointestinal tract. Inhalation may cause coughing, nose and throat irritation,
and sneezing. High exposures may cause difficulty breathing, congestion, and chest tightness.
Primary combustion products are carbon monoxide, carbon dioxide, and styrene.
There are no known chronic health effects connected with long-term use or contact with these products.
Release of cyanide gas?
Hydrogen cyanide is a by-product of the combustion of materials found in products used in everyday life (insulation, carpets, clothing, and synthetics). The culprit is nitrogen. Nitrogen gas in atmospheric air can contribute (under the right circumstances) to the formation of minute amounts of cyanide during combustion. High temperatures and low-oxygen concentrations favor the formation of cyanide gas. Smoke from the combustion of grass clippings, green wood, tobacco, cotton, paper, wool, silk, weeds, and animal carcasses will likely contain some hydrogen cyanide gas. Also watch out for the combustion of man-made plastic and resins containing nitrogen, especially if the fire is hot and in an enclosed space.
Cyanide exposure is an expected outcome of smoke inhalation in closed-space fires.
Reference: http://www.fireengineering.com/articles/2009/06/hydrogen-cyanide-new-concerns-for-firefighting-and-medical-tactics.html
Bottom line, to get the really bad stuff (like cyanide gas) you need an open flame fire in an enclosed space. Melting the foam won't release hydrogen cyanide gas - you need an open flame and black smoke for that. But notice, burning common household trash can also release cyanide gas. Generally speaking, anything that has nitrogen in it and burns hot enough to release a lot of smoke and look out.
Otherwise, melting the foam can release carbon monoxide, but probably in no larger doses that you'll get standing next to a busy freeway ...