To paraphrase dog trainers, there’s no such thing as bad foam, just bad boatbuilders/boaters.
Seriously, though, if foam is properly used it’s not a problem. The problem is that many builders do not understand its uses and, most importantly, its limitations and use it the wrong way in the wrong boats and that’s what results in the horror stories.
First off, the correct expanding foam for boats is the Coast Guard-approved, 2-part, closed cell, structural, 2 lb/cu ft polyurethane foam. It is is most certainly not the stuff in a spray can from the local DYI store. No one in this thread has mentioned using anything other than the correct stuff, but I see it all over the internet where someone uses the spray can stuff in their boats. That is a recipe for disaster.
Second, builders need to understand that the foam is there to provide emergency flotation in the event of a hull failure until the boat can get back to shore and repairs made. It is not meant to stand up to years of immersion in water. If the foam is getting wet, the emergency has already happened; the hull has failed. Continuing to use the boat in that condition is what causes the problems with waterlogged foam, not the unsuitability of the foam itself.
As Howard mentions, correct engineering is important. You can’t just start filling random compartments with no consideration for the surrounding structure. Ideally, the compartment should be stiff and watertight before the foam is added. That means proper sealing, inside and out, with epoxy encapsulation and even a layer of glass. The compartment should be vented when the foam is added to prevent the blowouts that Peter mentions. But most importantly, the reason for using the foam needs to be kept in mind. Compartments that are not at risk of puncture and not critical to keeping the boat afloat would probably do better with a different solution.
As a real world example, my 16-year-old Brand X dinghy has foam in a compartment in the bow and in a second compartment in the stern. In both cases the bottom of the compartment is also the bottom of the boat. These are the areas most likely to hit rocks and other obstacles. The remaining compartments are air-filled.
Constant maintenance is also a must. Foam-filled compartments can’t just be ignored because they’re sealed. In my boat I inspect the bottom of the boat several times a year, looking for scratches and gouges. I also do a tap test to see if the wood is changing (most likely as a result of water intrusion). This kind of inspection will find problems before they get out of hand.
To sum up, expanding foam is simply another tool. It’s not a panacea, nor does it need a blanket prohibition. Like every other boatbuilding tool, it needs to be understood and used where appropriate, keeping in mind its pros and cons.
Laszlo