Slackware's default compiler nowadays is gcc-4.1.2. If you need an older compiler from the 3.x series, then you may use the one from the pasture directory of the distribution.
The problem is that you cannot have them both, because the two packages have files with the same name. So, if you try to use installpkg to install the older compiler the installer will overwrite some gcc-4.1.2 files.
Fortunately, you don't need to compile gcc by your self. Eric Hameleers (alien bob) maintains an unofficial slackbuilds repository hosted in slackware. There is a gcc package: http://www.slackware.com/~alien/slackbuilds/gcc34/ which is compatible with the official one.