Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content

clang compiler fix

snuverink_j requested to merge snuverink_j/OPAL-src:clang-compiler-fix into master

This MR fixes compilation with clang of the master branch.

In the c++11 standard sqrt and pow are not necessarily constexpr functions (e.g. https://stackoverflow.com/questions/8622256/in-c11-is-sqrt-defined-as-constexpr). With the clang compiler I get the following errors:

OPAL/fork/src/src/Classic/Solvers/CollimatorPhysics.cpp:331:22: error: 
      constexpr variable 'K' must be initialized by a constant expression
  ...double K = 4.0 * pi * Physics::Avo * std::pow(Physics::r_e * m2cm, 2) * massElectron_keV;
            ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/jsnuverink/Documents/OPAL/fork/src/src/Classic/Solvers/CollimatorPhysics.cpp:331:52: note: 
      non-constexpr function 'pow<double, int>' cannot be used in a constant expression
    constexpr double K = 4.0 * pi * Physics::Avo * std::pow(Physics::r_e * m2cm, 2) * mass...


OPAL/fork/src/src/Classic/Solvers/CollimatorPhysics.cpp:429:22: error: 
      constexpr variable 'sqrtThreeInv' must be initialized by a constant expression
    constexpr double sqrtThreeInv = 1.0 / std::sqrt(3.0);
                     ^              ~~~~~~~~~~~~~~~~~~~~
/Users/jsnuverink/Documents/OPAL/fork/src/src/Classic/Solvers/CollimatorPhysics.cpp:429:43: note: 
      non-constexpr function 'sqrt' cannot be used in a constant expression
    constexpr double sqrtThreeInv = 1.0 / std::sqrt(3.0);
                                          ^
/usr/include/math.h:447:15: note: declared here
extern double sqrt(double);
              ^

Compiler version:

Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

In addition I deleted the using Physics::pi to improve consistency, since the Physics namespace was everywhere apart from one location explicitly used.

Edited by snuverink_j

Merge request reports