clang compiler fix
All threads resolved!
All threads resolved!
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
Activity
Filter activity
- Resolved by kraus
- Resolved by kraus
added Regression label
mentioned in commit cd1c97d9
- Resolved by frey_m
Please register or sign in to reply