Collection of fixes needed to compile with gcc12. Not yet sure whether or when I want to merge as it is backporting from recent Geant4 release, but want to be able to build in order to check build of other projects depending on Geant4.