From be829a98caf2268cdc0ea0c1a03a8d7c03b863e4 Mon Sep 17 00:00:00 2001
From: Matthias Maier <tamiko@43-1.org>
Date: Fri, 22 May 2020 14:06:07 -0500
Subject: [PATCH] bugfix

---
 cmake/checks/check_01_cxx_features.cmake              | 9 ++++++---
 include/deal.II/base/config.h.in                      | 2 +-
 include/deal.II/base/utilities.h                      | 2 +-
 include/deal.II/physics/elasticity/standard_tensors.h | 8 ++++----
 source/physics/elasticity/standard_tensors.cc         | 8 ++++----
 5 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/cmake/checks/check_01_cxx_features.cmake b/cmake/checks/check_01_cxx_features.cmake
index fd4f6c498b..11b1789e1b 100644
--- a/cmake/checks/check_01_cxx_features.cmake
+++ b/cmake/checks/check_01_cxx_features.cmake
@@ -251,13 +251,11 @@ ENDMACRO()
 #
 
 _set_up_cmake_required()
-
 _test_cxx14_support()
 
 IF(NOT DEAL_II_HAVE_CXX14)
   MESSAGE(STATUS "C++14 support not available. Try to set -std=c++14 explicitly")
   ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-std=c++14")
-  ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "/std:c++14")
   _set_up_cmake_required()
   _test_cxx14_support()
 ENDIF()
@@ -511,7 +509,12 @@ ENDIF()
 # We only run this check if we have CXX14 support, otherwise the use of constexpr
 # is limited (non-const constexpr functions for example).
 #
-IF(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+
+# MSVC has considerable problems with "constexpr", disable unconditionally
+# for now
+IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+  SET(DEAL_II_CXX14_CONSTEXPR_BUG true)
+ELSE()
   CHECK_CXX_COMPILER_BUG(
     "
     #define Assert(x,y) if (!(x)) throw y;
diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in
index 9b876ff034..a2c1d4cd16 100644
--- a/include/deal.II/base/config.h.in
+++ b/include/deal.II/base/config.h.in
@@ -136,7 +136,7 @@
 
 #cmakedefine DEAL_II_HAVE_FP_EXCEPTIONS
 #cmakedefine DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
-#cmakedefine DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#cmakedefine DEAL_II_CXX14_CONSTEXPR_BUG
 
 #cmakedefine DEAL_II_DEPRECATED @DEAL_II_DEPRECATED@
 #cmakedefine DEAL_II_FALLTHROUGH @DEAL_II_FALLTHROUGH@
diff --git a/include/deal.II/base/utilities.h b/include/deal.II/base/utilities.h
index 63be355f77..7166f96731 100644
--- a/include/deal.II/base/utilities.h
+++ b/include/deal.II/base/utilities.h
@@ -475,7 +475,7 @@ namespace Utilities
   constexpr T
   pow(const T base, const int iexp)
   {
-#if defined(DEBUG) && defined(DEAL_II_CXX14_CONSTEXPR_BUG_OK)
+#if defined(DEBUG) && !defined(DEAL_II_CXX14_CONSTEXPR_BUG)
     // Up to __builtin_expect this is the same code as in the 'Assert' macro.
     // The call to __builtin_expect turns out to be problematic.
     if (!(iexp >= 0))
diff --git a/include/deal.II/physics/elasticity/standard_tensors.h b/include/deal.II/physics/elasticity/standard_tensors.h
index dd8d355c67..d24820e985 100644
--- a/include/deal.II/physics/elasticity/standard_tensors.h
+++ b/include/deal.II/physics/elasticity/standard_tensors.h
@@ -70,7 +70,7 @@ namespace Physics
        * matrix, then this simply corresponds to the identity matrix.
        */
       static DEAL_II_CONSTEXPR const SymmetricTensor<2, dim> I
-#ifdef DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#ifndef DEAL_II_CXX14_CONSTEXPR_BUG
         = unit_symmetric_tensor<dim>()
 #endif
         ;
@@ -103,7 +103,7 @@ namespace Physics
        * operator.
        */
       static DEAL_II_CONSTEXPR const SymmetricTensor<4, dim> S
-#ifdef DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#ifndef DEAL_II_CXX14_CONSTEXPR_BUG
         = identity_tensor<dim>()
 #endif
         ;
@@ -119,7 +119,7 @@ namespace Physics
        * @f]
        */
       static DEAL_II_CONSTEXPR const SymmetricTensor<4, dim> IxI
-#ifdef DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#ifndef DEAL_II_CXX14_CONSTEXPR_BUG
         = outer_product(unit_symmetric_tensor<dim>(),
                         unit_symmetric_tensor<dim>())
 #endif
@@ -169,7 +169,7 @@ namespace Physics
        * @dealiiHolzapfelA{232,6.105}
        */
       static DEAL_II_CONSTEXPR const SymmetricTensor<4, dim> dev_P
-#ifdef DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#ifndef DEAL_II_CXX14_CONSTEXPR_BUG
         = deviator_tensor<dim>()
 #endif
         ;
diff --git a/source/physics/elasticity/standard_tensors.cc b/source/physics/elasticity/standard_tensors.cc
index 886a7ff220..546b0cee62 100644
--- a/source/physics/elasticity/standard_tensors.cc
+++ b/source/physics/elasticity/standard_tensors.cc
@@ -24,7 +24,7 @@ DEAL_II_NAMESPACE_OPEN
 template <int dim>
 DEAL_II_CONSTEXPR const SymmetricTensor<2, dim>
                         Physics::Elasticity::StandardTensors<dim>::I
-#  ifndef DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#  ifdef DEAL_II_CXX14_CONSTEXPR_BUG
   = unit_symmetric_tensor<dim>()
 #  endif
   ;
@@ -34,7 +34,7 @@ DEAL_II_CONSTEXPR const SymmetricTensor<2, dim>
 template <int dim>
 DEAL_II_CONSTEXPR const SymmetricTensor<4, dim>
                         Physics::Elasticity::StandardTensors<dim>::S
-#  ifndef DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#  ifdef DEAL_II_CXX14_CONSTEXPR_BUG
   = identity_tensor<dim>()
 #  endif
   ;
@@ -44,7 +44,7 @@ DEAL_II_CONSTEXPR const SymmetricTensor<4, dim>
 template <int dim>
 DEAL_II_CONSTEXPR const SymmetricTensor<4, dim>
                         Physics::Elasticity::StandardTensors<dim>::IxI
-#  ifndef DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#  ifdef DEAL_II_CXX14_CONSTEXPR_BUG
   = outer_product(unit_symmetric_tensor<dim>(), unit_symmetric_tensor<dim>())
 #  endif
   ;
@@ -54,7 +54,7 @@ DEAL_II_CONSTEXPR const SymmetricTensor<4, dim>
 template <int dim>
 DEAL_II_CONSTEXPR const SymmetricTensor<4, dim>
                         Physics::Elasticity::StandardTensors<dim>::dev_P
-#  ifndef DEAL_II_CXX14_CONSTEXPR_BUG_OK
+#  ifdef DEAL_II_CXX14_CONSTEXPR_BUG
   = deviator_tensor<dim>()
 #  endif
   ;
-- 
2.39.5