]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Don't use __builtin_expect in Utilities::pow 7644/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 26 Jan 2019 15:13:16 +0000 (16:13 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 26 Jan 2019 15:36:34 +0000 (16:36 +0100)
include/deal.II/base/utilities.h

index f2a1cb6b6e1bf6bcdfc6bee232fd178bf2cae8c7..f49c3021321b07040b3bb5086cc86a13646c2203 100644 (file)
@@ -404,9 +404,10 @@ namespace Utilities
   constexpr unsigned int
   pow(const unsigned int base, const int iexp)
   {
-#ifdef DEAL_II_WITH_CXX14
-#  ifdef DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR
-#    if defined(DEAL_II_HAVE_BUILTIN_EXPECT) && defined(__INTEL_COMPILER)
+#if defined(DEBUG) && defined(DEAL_II_WITH_CXX14) && \
+  defined(DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR)
+    // 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))
       ::dealii::deal_II_exceptions::internals::issue_error_noreturn(
         ::dealii::deal_II_exceptions::internals::abort_or_throw_on_exception,
@@ -416,10 +417,6 @@ namespace Utilities
         "iexp>=0",
         "ExcMessage(\"The exponent must not be negative!\")",
         ExcMessage("The exponent must not be negative!"));
-#    else
-    Assert(iexp >= 0, ExcMessage("The exponent must not be negative!"));
-#    endif
-#  endif
 #endif
     // The "exponentiation by squaring" algorithm used below has to be
     // compressed to one statement due to C++11's restrictions on constexpr

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.