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
Snippets Groups Projects

clang compiler fix

Merged snuverink_j requested to merge snuverink_j/OPAL-src:clang-compiler-fix into master
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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • kraus
  • snuverink_j added 1 commit

    added 1 commit

    • 1410a0be - change as suggested by Christof

    Compare with previous version

  • kraus approved this merge request

    approved this merge request

  • kraus resolved all discussions

    resolved all discussions

  • added Regression label

  • snuverink_j changed the description

    changed the description

  • frey_m approved this merge request

    approved this merge request

  • merged

  • snuverink_j mentioned in commit cd1c97d9

    mentioned in commit cd1c97d9

  • frey_m
  • frey_m resolved all discussions

    resolved all discussions

  • Please register or sign in to reply
    Loading