This is one avenue to a solution. I am indebted to [Thomas Dickey answer](https://unix.stackexchange.com/a/346134/132913) for having put me in the right direction.

The problem is that the custom-installed compiler gcc 6.3.0 cannot find the key files of the `libstdc++` family that, in the Ubuntu distribution, are contained within `/usr/include/`.

At point of installation, the configure file for gcc 6.3.0 itself silently followed the default specification as for the target directory where to find local (previously installed) header files. This default is `/usr/local/include/`. See https://gcc.gnu.org/install/configure.html for details.

The compiler reinstalled with the `./configure --with-local-prefix=/usr` has created a new gcc that is able to fetch the required files where Ubuntu has put them. No further adjustement of the `CPPFLAGS` is needed with respect to what has been shown in the question.

The empirical test for this strategy is that the `make` of HDF 1.8.18 proceeds where it once got stranded and all tests in the `make check` are passed successfully. 

I have note explored (yet) the other avenue of installing a fresh `libstdc++` library that serves specifically the custom install of gcc. I have added a new question in the frame above in search of cues. That might well be a more robust solution. The thread remains open for the moment. Thanks for contributing/editing