[Gc] Removal of "function returns address of local variable" warning

Ivan Maidanski ivmai at mail.ru
Sat Oct 25 07:47:33 PDT 2008


Hi!

This tiny patch eliminates "function returns address of local variable" warning in GC_approx_sp() ("mark_rts.c" file) in a compiler-neutral way. The functionality remains unchanged.

Bye.

-------------- next part --------------
diff -ru bdwgc/mark_rts.c updated/bdwgc/mark_rts.c
--- bdwgc/mark_rts.c	2008-10-16 16:25:34.000000000 +0400
+++ updated/bdwgc/mark_rts.c	2008-10-25 18:15:18.000000000 +0400
@@ -353,19 +353,13 @@
 
 ptr_t GC_approx_sp(void)
 {
-    volatile word dummy;
-
-    dummy = 42;	/* Force stack to grow if necessary.	Otherwise the	*/
+    volatile word sp;
+    sp = (word)&sp;
+		/* Also force stack to grow if necessary. Otherwise the	*/
     		/* later accesses might cause the kernel to think we're	*/
     		/* doing something wrong.				*/
-#   ifdef _MSC_VER
-#     pragma warning(disable:4172)
-#   endif
-	/* Ignore "function returns address of local variable" warning.	*/
-    return((ptr_t)(&dummy));
-#   ifdef _MSC_VER
-#     pragma warning(default:4172)
-#   endif
+
+    return((ptr_t)sp);
 }
 
 /*


More information about the Gc mailing list