[PATCH] testsuite,clang: fix malloc04 and malloctest for on clang

Daniel Hellstrom daniel at gaisler.com
Fri Oct 5 06:57:53 UTC 2018


malloc04 and malloctest tests from the rtems test-suite fails
when checking the return value of malloc(). The check is
optimized away and always fails.
---
 testsuites/libtests/malloc04/init.c   |  2 +-
 testsuites/libtests/malloctest/init.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/testsuites/libtests/malloc04/init.c b/testsuites/libtests/malloc04/init.c
index 632ea28..73023d6 100644
--- a/testsuites/libtests/malloc04/init.c
+++ b/testsuites/libtests/malloc04/init.c
@@ -79,7 +79,7 @@ rtems_task Init(
 {
   Heap_Control *real_heap;
   Heap_Area area;
-  void *p;
+  static void *p;
 
   TEST_BEGIN();
 
diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c
index 577f557..d89f630 100644
--- a/testsuites/libtests/malloctest/init.c
+++ b/testsuites/libtests/malloctest/init.c
@@ -1378,11 +1378,11 @@ rtems_task Init(
 
 static void test_early_malloc( void )
 {
-  void *p;
-  char *q;
-  void *r;
-  void *s;
-  void *t;
+  static void *p;
+  static char *q;
+  static void *r;
+  static void *s;
+  static void *t;
 
   p = malloc( 1 );
   rtems_test_assert( p != NULL );
-- 
2.7.4



More information about the devel mailing list