Created
August 25, 2012 18:50
-
-
Save stepancheg/3469192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
struct large_struct { | |
void* a[1024]; | |
}; | |
static void foo() { | |
struct large_struct r; | |
// call any function that is guaranteed to be not inlined | |
write(-1, (void*) &r, 1); | |
} | |
static void bar(int n) { | |
if (n > 0) { | |
foo(); | |
bar(n - 1); | |
} | |
} | |
// crashes when compiled by clang or llvm-gcc with -O2 | |
// works fine with -O0 or in gcc | |
// reported to LLVM: http://llvm.org/bugs/show_bug.cgi?id=13700 | |
int main() { | |
int ns[] = { 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000 }; | |
for (int i = 0; i < sizeof(ns) / sizeof(int); ++i) { | |
printf("%d\n", ns[i]); | |
bar(ns[i]); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment