While this has been re-assigned to gcc as a compiler regression, let me just mention for the HepMC3 maintainers, that there is a workaround from the authors which makes HepMC3 compile again:
https://gitlab.cern.ch/hepmc/HepMC3/-/commit/ba38f14d8f56c16cc4105d98f6d4540c928c6150 (That patch is for HepMC 3.2.1, but given the error looks the same it probably also applies to 3.1.2 which you have in Debian.) Best, Frank PS: This is also being used in the Archlinux package now and fixes the same compilation issue there (https://aur.archlinux.org/packages/hepmc3/ -> View PKGBUILD).