From 1c96039d7a1146a50b52335e0af8623f97f98415 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Mon, 15 Sep 2014 19:46:43 +0200 Subject: [PATCH] - Fixed miscompilation with Clang 3.5.0. The optimizer miscompiles the function FBehavior::LoadScriptsDirectory and causes random crashes when zdoom is run with wads containing scripts. As said in the comment, I just hope that the Clang devs fix it for the next patching release, ie 3.5.1. --- src/p_acs.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 235a47933..405d60320 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2306,6 +2306,12 @@ void FBehavior::LoadScriptsDirectory () default: break; } + +// [EP] Clang 3.5.0 optimizer miscompiles this function and causes random +// crashes in the program. I hope that Clang 3.5.x will fix this. +#if defined(__clang__) && __clang_major__ == 3 && __clang_minor__ >= 5 + asm("" : "+g" (NumScripts)); +#endif for (i = 0; i < NumScripts; ++i) { Scripts[i].Flags = 0;