CUdToolkit 8.0 (or 9) gives errors while compiling with gnu gcc 7.2.x

I use a Lenovo Legion Y520 laptop, with GeForce 1050 Ti GPU and operates on Slackware-current (29th Dec 2017 version). GNU gcc 7.2.x compiler is used. While trying to compile and install OpenCV and also several *.cpp examples I get the error:
unsupported GNU version! gcc versions later than 5 are not supported!

This error seems to arise from the file:
wherein the gcc version number is tested and if more than 5, the error is raised.
One suggestion found on digging the Internet is to simply comment out the test (!), but that raises even more errors.

I am extremely reluctance to replace the GNU 7.2.x tool-chain (by, say, GNU 5.3.x in the original Slackware 14.2) as I use it for several other projects.

Till the Nvidia package and GNU meet some where regarding compiler usable versions, the GPU remains almost a decorative piece, good for running only the vendor supplied “samples”.

Don’t know about Slackware but can’t you install different gcc versions side by side and then just link the right one to cuda/bin/gcc?