It can be avoided by not letting the instrument become cold to start with, or if unavoidable, by letting the instrument slowly return to a reasonable temperature. Extreme heat also plays havoc with your collectible guitar by loosening glue joints at the neck, rims, and fingerboard, and warping necks. Hot summer days can be tough on an exposed guitar. When considering long-term storage for your valuable instruments, consider where you are personally comfortable in your house and select an area where the ambient temperature is similar. For example, last time you went to your attic, you may have noticed it was stuffy and hot in the daytime and chilly at night.
Attics are very poor storage areas for guitars.
The heat can cause pickguards to curl, and it can damage wood and glue joints. The cold can cause cracking of plastic parts and possible finish checking. Unless your attic has heat and air conditioning, avoid putting instruments there. Humidity and moisture are generally bad for your guitar. It causes the wood to swell and grow mildew.