Skip to content

Instantly share code, notes, and snippets.

@stepancheg
Created August 25, 2012 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stepancheg/3469192 to your computer and use it in GitHub Desktop.
Save stepancheg/3469192 to your computer and use it in GitHub Desktop.
#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