2016-06-21 9 views
0

私のプロジェクトではMingw-w64コンパイラを使用しています。今私はMSVC2015でプロジェクトをコンパイルしています。次の行はエラーを与える:MSVC 2015はconstexpr atanをコンパイルできません

constexpr double pi = 4*std::atan(1); 

エラー:

それは何の問題もなくmingwのでコンパイルしかし
error: C2131: expression did not evaluate to a constant 

+0

おそらくstd :: atan()はMingw-w64コンパイラのconstexprであり、MSVC2015の実装ではありません。この機能の比較 Mingw-64に同梱のヘッダファイルとVisual Studioに同梱のファイル – mvidelgauz

+0

のヘッダファイルはgccのバグのようです。 ClangとMSVSはどちらもコードを正しく拒否します。 – NathanOliver

答えて

0

私は§26.8

In addition to the double versions of the math functions in , C++ adds float and long double overloaded versions of these functions, with the same semantics.

からこれは数学関数がconstexprていない、または他の彼らはCと同等と同じ意味を持っていないことを暗示する、MSVC、この場合には正しいと思います。

したがって、std::atanconstexpr関数ではないため、constexpr式で使用することは不正です。

関連する問題