The gable vent is actually both intake and exhaust, depending on which way the wind blows at the moment. If you exhaust right into the opening, there's a good chance the wind will blow it right back into the attic space. Moisture accumulating in the attic may or may not be a big problem, very much depends on where you live. If the climate is already dump and warm, you may have mold growth and wood rot, with implications escalating themselves all the way up to the horror stories of roof collapses. If the area is dry, a bathroom exhaust may not be such a big deal and besides, we are not talking about venting it straight into the attic (which I would avoid even in dry climate), we are talking about a possibility that wind will blow it back into the attic, presumably not 100% of the time. Â
However, as far as code compliance: if your municipality has already adopted the 2009 version or the International Residential Code, it <strong>almost</strong> explicitly prohibits venting into a gable vent. Gable vents are not mentioned as such but the addition of ridge and soffit vents to the code makes it very easy for a building inspector to throw the gable vents into the same mix:
<q>M1501.1 Outdoor discharge. The air removed by every mechanical exhaust system shall be discharged to the outdoors. Air shall not be exhausted into an attic, soffit, ridge vent or crawl space.</q>
It further emphasizes the point in section M1507 Mechanical Ventilation: <q>
M1507.2 Recirculation of air. Exhaust air from bathrooms and toilet rooms shall not be recirculated within a residence or to another dwelling unit and shall be exhausted directly to the outdoors. Exhaust air from bathrooms and toilet rooms shall not discharge into an attic, crawl space or other areas inside the building </q>
 In other words, to install a bathroom fan in a clear-cut code compliant way you do need to make a hole in the siding. Just like you, I would avoid penetrating the roof if I can.