Problem 2444 - Geant4 10.7.2 fails to build from sources with GCC 11.2.1 on Fedora.
Summary: Geant4 10.7.2 fails to build from sources with GCC 11.2.1 on Fedora.
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: global/management (show other problems)
Version: 10.7
Hardware: All Linux
: P4 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2021-11-16 08:04 CET by andrii.verbytskyi@mpp.mpg.de
Modified: 2021-11-16 10:26 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description andrii.verbytskyi@mpp.mpg.de 2021-11-16 08:04:20 CET
Geant4 10.7.2 fails to build from sources with GCC 11.2.1 on Fedora.

```
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:73:10: error: ambiguating new declaration of 'G4double fsqrt(G4double)'
   73 | G4double fsqrt(G4double arg) { return std::sqrt(arg); }
      |          ^~~~~
In file included from /usr/include/c++/11/cmath:45,
                 from /usr/include/c++/11/complex:44,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4Types.hh:74,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4ios.hh:35,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/globals.hh:35,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4ThreeVector.hh:33,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/include/G4tgrEvaluator.hh:37,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:31:
/usr/include/bits/mathcalls-narrow.h:36:20: note: old declaration 'float fsqrt(double)'
   36 | __MATHCALL_NARROW (__MATHCALL_NAME (sqrt), __MATHCALL_REDIR_NAME2 (sqrt), 1);
      |                    ^~~~~~~~~~~~~~~
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc: In member function 'void G4tgrEvaluator::AddCommonFunctions()':
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:95:14: error: no matching function for call to 'setFunction(const char [5], float (&)(double) noexcept)'
   95 |   setFunction("sqrt", (*fsqrt));
      |   ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4Evaluator.hh:33,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/include/G4tgrEvaluator.hh:38,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:31:
/usr/include/CLHEP/Evaluator/Evaluator.h:126:8: note: candidate: 'void HepTool::Evaluator::setFunction(const char*, double (*)())' (near match)
  126 |   void setFunction(const char * name, double (*fun)());
      |        ^~~~~~~~~~~
/usr/include/CLHEP/Evaluator/Evaluator.h:126:8: note:   conversion of argument 2 would be ill-formed:
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:95:24: error: invalid conversion from 'float (*)(double) noexcept' {aka 'float (*)(double)'} to 'double (*)()' [-fpermissive]
   95 |   setFunction("sqrt", (*fsqrt));
      |                       ~^~~~~~~
      |                        |
      |                        float (*)(double) noexcept {aka float (*)(double)}
In file included from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4Evaluator.hh:33,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/include/G4tgrEvaluator.hh:38,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:31:
/usr/include/CLHEP/Evaluator/Evaluator.h:136:8: note: candidate: 'void HepTool::Evaluator::setFunction(const char*, double (*)(double))' (near match)
  136 |   void setFunction(const char * name, double (*fun)(double));
      |        ^~~~~~~~~~~
/usr/include/CLHEP/Evaluator/Evaluator.h:136:8: note:   conversion of argument 2 would be ill-formed:
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:95:24: error: invalid conversion from 'float (*)(double) noexcept' {aka 'float (*)(double)'} to 'double (*)(double)' [-fpermissive]
   95 |   setFunction("sqrt", (*fsqrt));
      |                       ~^~~~~~~
      |                        |
      |                        float (*)(double) noexcept {aka float (*)(double)}
In file included from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4Evaluator.hh:33,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/include/G4tgrEvaluator.hh:38,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:31:
/usr/include/CLHEP/Evaluator/Evaluator.h:146:8: note: candidate: 'void HepTool::Evaluator::setFunction(const char*, double (*)(double, double))' (near match)
  146 |   void setFunction(const char * name, double (*fun)(double,double));
      |        ^~~~~~~~~~~
/usr/include/CLHEP/Evaluator/Evaluator.h:146:8: note:   conversion of argument 2 would be ill-formed:
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:95:24: error: invalid conversion from 'float (*)(double) noexcept' {aka 'float (*)(double)'} to 'double (*)(double, double)' [-fpermissive]
   95 |   setFunction("sqrt", (*fsqrt));
      |                       ~^~~~~~~
      |                        |
      |                        float (*)(double) noexcept {aka float (*)(double)}
In file included from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4Evaluator.hh:33,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/include/G4tgrEvaluator.hh:38,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:31:
/usr/include/CLHEP/Evaluator/Evaluator.h:156:8: note: candidate: 'void HepTool::Evaluator::setFunction(const char*, double (*)(double, double, double))' (near match)
  156 |   void setFunction(const char * name, double (*fun)(double,double,double));
      |        ^~~~~~~~~~~
/usr/include/CLHEP/Evaluator/Evaluator.h:156:8: note:   conversion of argument 2 would be ill-formed:
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:95:24: error: invalid conversion from 'float (*)(double) noexcept' {aka 'float (*)(double)'} to 'double (*)(double, double, double)' [-fpermissive]
   95 |   setFunction("sqrt", (*fsqrt));
      |                       ~^~~~~~~
      |                        |
      |                        float (*)(double) noexcept {aka float (*)(double)}
In file included from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4Evaluator.hh:33,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/include/G4tgrEvaluator.hh:38,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:31:
/usr/include/CLHEP/Evaluator/Evaluator.h:166:8: note: candidate: 'void HepTool::Evaluator::setFunction(const char*, double (*)(double, double, double, double))' (near match)
  166 |   void setFunction(const char * name,
      |        ^~~~~~~~~~~
/usr/include/CLHEP/Evaluator/Evaluator.h:166:8: note:   conversion of argument 2 would be ill-formed:
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:95:24: error: invalid conversion from 'float (*)(double) noexcept' {aka 'float (*)(double)'} to 'double (*)(double, double, double, double)' [-fpermissive]
   95 |   setFunction("sqrt", (*fsqrt));
      |                       ~^~~~~~~
      |                        |
      |                        float (*)(double) noexcept {aka float (*)(double)}
In file included from /builddir/build/BUILD/geant4.10.07.p02/source/global/management/include/G4Evaluator.hh:33,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/include/G4tgrEvaluator.hh:38,
                 from /builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:31:
/usr/include/CLHEP/Evaluator/Evaluator.h:177:8: note: candidate: 'void HepTool::Evaluator::setFunction(const char*, double (*)(double, double, double, double, double))' (near match)
  177 |   void setFunction(const char * name,
      |        ^~~~~~~~~~~
/usr/include/CLHEP/Evaluator/Evaluator.h:177:8: note:   conversion of argument 2 would be ill-formed:
/builddir/build/BUILD/geant4.10.07.p02/source/persistency/ascii/src/G4tgrEvaluator.cc:95:24: error: invalid conversion from 'float (*)(double) noexcept' {aka 'float (*)(double)'} to 'double (*)(double, double, double, double, double)' [-fpermissive]
   95 |   setFunction("sqrt", (*fsqrt));
      |                       ~^~~~~~~
      |                        |
      |                        float (*)(double) noexcept {aka float (*)(double)}
gmake[2]: *** [source/CMakeFiles/G4persistency.dir/build.make:401: source/CMakeFiles/G4persistency.dir/persistency/ascii/src/G4tgrEvaluator.cc.o] Error 1
gmake[2]: Leaving directory '/builddir/build/BUILD/geant4.10.07.p02/redhat-linux-build'
gmake[1]: *** [CMakeFiles/Makefile2:3445: source/CMakeFiles/G4persistency.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
```

Best regards,

Andrii
Comment 1 Gabriele Cosmo 2021-11-16 08:48:10 CET
Thanks for reporting the issue. A fix will be provided soon.
Note however that gcc-11 is NOT supported for release 10.7 series. The list of all supported platforms/compilers are reported in the release notes.
Comment 2 andrii.verbytskyi@mpp.mpg.de 2021-11-16 10:22:35 CET
(In reply to Gabriele Cosmo from comment #1)
> Thanks for reporting the issue. A fix will be provided soon.
> Note however that gcc-11 is NOT supported for release 10.7 series. The list
> of all supported platforms/compilers are reported in the release notes.

Thank you, Gabriele! Will wait for the fix.( Sorry for not submitting a patch). I know that gcc-11 is still very new and not officially supported, but it is better to report the problem early.

Best regards,

Andrii
Comment 3 Gabriele Cosmo 2021-11-16 10:26:37 CET
Try simply renaming that free function in G4tgrEvaluator.cc from "fsqrt" to "fltsqrt" (also called few lines after in the same method), and see if that makes compilation succeed.