[PATCH] Fix "#pragma clang __debug overflow_stack" for MSVC builds
Richard Smith
richard at metafoo.co.uk
Thu Aug 28 14:40:41 PDT 2014
================
Comment at: lib/Lex/Pragma.cpp:928-932
@@ -927,6 +927,7 @@
#endif
static void DebugOverflowStack() {
+ void* StackUser = &StackUser;
void (*volatile Self)() = DebugOverflowStack;
Self();
}
#ifdef _MSC_VER
----------------
rsmith wrote:
> A smart compiler could still optimize out the stack usage here. How about using something that keeps all the stack memory live, such as:
>
> volatile void *Head;
> static void DebugOverflowStack(void *Curr = 0) {
> Head = Curr;
> DebugOverflowStack(&Curr);
> }
>
> Hopefully MSVC doesn't optimize out stores to volatile globals...
Sorry, should be
void *volatile Head;
http://reviews.llvm.org/D5109
More information about the cfe-commits
mailing list