From 57dfcb9bb93ea93be4e97df6eb36be3f6f16be90 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Thu, 25 Jul 2019 00:38:19 -0400 Subject: [PATCH] Disable __builtin_expect for Intel compiler with constexpr enabled --- cmake/checks/check_02_compiler_features.cmake | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmake/checks/check_02_compiler_features.cmake b/cmake/checks/check_02_compiler_features.cmake index e0f3225214..2ac63a12fb 100644 --- a/cmake/checks/check_02_compiler_features.cmake +++ b/cmake/checks/check_02_compiler_features.cmake @@ -120,14 +120,21 @@ CHECK_CXX_COMPILER_BUG( # prediction unit in some cases. We use it in the AssertThrow # macros. # +# Intel compilers don't handle __builtin_expect in C++14 constexpr contexts +# properly so we disable this feature in case we are going to use +# DEAL_II_CONSTEXPR with an Intel compiler. +# # - Matthias Maier, rewritten 2012 # -CHECK_CXX_SOURCE_COMPILES( - " - bool f() { return true; } - int main(){ if (__builtin_expect(f(),false)) {} } - " - DEAL_II_HAVE_BUILTIN_EXPECT) +IF(NOT(CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND + DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR)) + CHECK_CXX_SOURCE_COMPILES( + " + bool f() { return true; } + int main(){ if (__builtin_expect(f(),false)) {} } + " + DEAL_II_HAVE_BUILTIN_EXPECT) +ENDIF() # -- 2.39.5