Bug #1288

BornAgain does not compile on mac os x (problem with constexpr ... sqrt)

Added by ganeva about 4 years ago. Updated about 4 years ago.

Status:ResolvedStart date:02 Feb 2016
Priority:NormalDue date:
Assignee:wuttke% Done:

100%

Category:-
Target version:-

Description

The error is caused by FormFactorTetrahedron.cpp:

The compiler information:

================

-- The C compiler identification is AppleClang 7.0.2.7000181
-- The CXX compiler identification is AppleClang 7.0.2.7000181
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
[...]
-- Compiler Flags: -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -I/Users/ganeva/build/bornagain/BornAgain/Core/Tools/inc -include WinDllMacros.h -std=c++11 -O2

================

The error message:

============

Users/ganeva/build/bornagain/BornAgain/Core/FormFactors/src/FormFactorTetrahedron.cpp:86:22: error: constexpr variable 'root3'
must be initialized by a constant expression
constexpr double root3 = std::sqrt(3.);
^ ~~~~~~~~~~~
/Users/ganeva/build/bornagain/BornAgain/Core/FormFactors/src/FormFactorTetrahedron.cpp:86:30: note: non-constexpr function 'sqrt'
cannot be used in a constant expression
constexpr double root3 = std::sqrt(3.);
^
/usr/include/math.h:447:15: note: declared here
extern double sqrt(double);
^
/Users/ganeva/build/bornagain/BornAgain/Core/FormFactors/src/FormFactorTetrahedron.cpp:115:22: error: constexpr variable 'root3'
must be initialized by a constant expression
constexpr double root3 = std::sqrt(3.);
^ ~~~~~~~~~~~
/Users/ganeva/build/bornagain/BornAgain/Core/FormFactors/src/FormFactorTetrahedron.cpp:115:30: note: non-constexpr function 'sqrt'
cannot be used in a constant expression
constexpr double root3 = std::sqrt(3.);
^
/usr/include/math.h:447:15: note: declared here
extern double sqrt(double);

============

History

#1 Updated by ganeva about 4 years ago

  • Description updated (diff)

#2 Updated by wuttke about 4 years ago

  • Subject changed from BornAgain does not compile on mac os x to BornAgain does not compile on mac os x (problem with constexpr ... sqrt)

#3 Updated by wuttke about 4 years ago

  • Assignee set to wuttke

#4 Updated by wuttke about 4 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Indeed, sqrt is non-constexpr according to the standard, though it is tolerate by g++.

Fixed in develop/650f42d

Also available in: Atom PDF