crt: testcases: Avoid compiler optimization of the null pointer write

Previously, the compiler would know for certain, that the
written pointer is a null pointer, which is UB. Therefore,
Clang would assume that the UB code is unreachable, and not
generate any code for anything after the call to printf.

Move the pointer variable to the global scope, to make the
compiler unable to assume anything about its value here,
retaining the write and the rest of the main function.

This fixes hangs in this testcase on armv7 with msvcrt.

Signed-off-by: Martin Storsjö <martin@martin.st>
1 file changed