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ö <mar...@martin.st>
---
 mingw-w64-crt/testcases/t_nullptrexception.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/testcases/t_nullptrexception.c 
b/mingw-w64-crt/testcases/t_nullptrexception.c
index d1ae83c24..3c2c47ade 100644
--- a/mingw-w64-crt/testcases/t_nullptrexception.c
+++ b/mingw-w64-crt/testcases/t_nullptrexception.c
@@ -1,9 +1,9 @@
 #include <stdio.h>
 
+char *p = NULL;
+
 int main()
 {
-  char *p = NULL;
-
   printf ("Raise uncaught NULL pointer exception...\n");
   *p = 0;
   return 0;
-- 
2.43.0



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to