]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Restrict C++17 check 6639/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 20 May 2018 23:49:02 +0000 (01:49 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 21 May 2018 07:59:06 +0000 (09:59 +0200)
cmake/checks/check_01_cxx_features.cmake

index 6c4b9733814dc6367d0fca55d34a3b0b136d1e54..d46f34baf6bc52797d161518b31b0e8e35620058 100644 (file)
@@ -176,11 +176,42 @@ IF(NOT DEFINED DEAL_II_WITH_CXX17 OR DEAL_II_WITH_CXX17)
       "
       DEAL_II_HAVE_CXX17_IF_CONSTEXPR)
 
+    #
+    # Some compilers treat lambdas as constexpr functions when compiling
+    # with C++17 support even if they don't fulfill all the constexpr
+    # function requirements. Consequently, these compilers don't allow
+    # try-blocks or non-literal return types in lambdas. This is a bug.
+    #
+    CHECK_CXX_SOURCE_COMPILES(
+      "
+      #include <string>
+
+      int main()
+      {
+        auto c = []()
+        {
+          return std::string{};
+        }();
+        (void) c;
+
+        return []()
+        {
+          try
+          {}
+          catch(...)
+          {}
+          return 0;
+        }();
+      }
+      "
+      DEAL_II_NON_CONSTEXPR_LAMBDA)
+
     RESET_CMAKE_REQUIRED()
   ENDIF()
 
   IF( DEAL_II_HAVE_CXX17_ATTRIBUTES AND
-      DEAL_II_HAVE_CXX17_IF_CONSTEXPR)
+      DEAL_II_HAVE_CXX17_IF_CONSTEXPR AND
+      DEAL_II_NON_CONSTEXPR_LAMBDA)
     SET(DEAL_II_HAVE_CXX17 TRUE)
   ELSE()
     IF(NOT _user_provided_cxx_version_flag)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.