summaryrefslogtreecommitdiff
path: root/tests/projects/c/filc/safety_test/src/main.c
blob: d23718c3ebd232af685c362db18c71ba14872380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* Test that filc catches calling a function pointer with a wrong address.
 *
 * Expected runtime output (exit non-zero):
 *   filc safety error: cannot access pointer as function with ptr != aux ...
 *   filc panic: thwarted a futile attempt to violate memory safety.
 */
#include <stdfil.h>
#include <stdlib.h>

static void foo(void) {
}

int main() {
    void (*my_foo)(void) = (void(*)(void))((char*)foo + 42);
    my_foo();
    return 0;
}