about summary refs log tree commit diff homepage
path: root/test/Runtime/klee-libc/atexit_order.c
blob: f8ebb16081323bcecfe6c12c4909e9f754efb129 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// RUN: %clang %s -emit-llvm %O0opt -c -o %t1.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out --exit-on-error --libc=klee %t1.bc

// make sure the functions passed to atexit are called in reverse order

#include <assert.h>

extern void atexit(void (*)());

static int counter = 0;

void first() {
  assert(counter == 0);
  ++counter;
}

void second() {
  assert(counter == 1);
  ++counter;
}

int main() {
  atexit(second);
  atexit(first);
  return 0;
}