Skip to content

Commit b8be103

Browse files
authored
Fix FC_NO_TAILCALL with newer compilers (#45999)
The C11 standard treats trivial infinite loops as undefined behavior and allows compilers to optimize them out completely. Add "volatile" on FC_NO_TAILCALL to defeat this optimization
1 parent a955eaf commit b8be103

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/coreclr/vm/ecall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void ECall::PopulateManagedCastHelpers()
185185
static CrstStatic gFCallLock;
186186

187187
// This variable is used to force the compiler not to tailcall a function.
188-
int FC_NO_TAILCALL;
188+
RAW_KEYWORD(volatile) int FC_NO_TAILCALL;
189189

190190
#endif // !DACCESS_COMPILE
191191

src/coreclr/vm/fcall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ void HCallAssert(void*& cache, void* target);
926926
// might do, which would otherwise confuse the epilog walker.
927927
//
928928
// * See #FC_INNER for more
929-
extern int FC_NO_TAILCALL;
929+
extern RAW_KEYWORD(volatile) int FC_NO_TAILCALL;
930930
#define FC_INNER_RETURN(type, expr) \
931931
type __retVal = expr; \
932932
while (0 == FC_NO_TAILCALL) { }; /* side effect the compile can't remove */ \

0 commit comments

Comments
 (0)