Hi

    I am having this warning:

/home/fdt/dev/gcc/git/libstdc++-v3/testsuite/util/testsuite_performance.h:170: attention: ignoring return value of « void* malloc(size_t) » declared with attribute « warn_unused_result » [-Wunused-result]
  170 |       malloc(0); // Needed for some implementations.

    Ok to fix it with attached patch ?

    It seems trivial but I wonder if I shouldn't keep the malloc returned pointer and free it properly ?

    Or maybe just remove the malloc cause there is not clear comment explaining why it's needed and I haven't found much in SVN audit trail.

    * testsuite_files/util/testsuite_performance.h
    (resource_counter::start): Ignore unused malloc(0) result.

François

diff --git a/libstdc++-v3/testsuite/util/testsuite_performance.h b/libstdc++-v3/testsuite/util/testsuite_performance.h
index 556c78159be..8abc77cf31a 100644
--- a/libstdc++-v3/testsuite/util/testsuite_performance.h
+++ b/libstdc++-v3/testsuite/util/testsuite_performance.h
@@ -167,7 +167,7 @@ namespace __gnu_test
     {
       if (getrusage(who, &rusage_begin) != 0 )
 	memset(&rusage_begin, 0, sizeof(rusage_begin));
-      malloc(0); // Needed for some implementations.
+      void* p __attribute__((unused)) = malloc(0); // Needed for some implementations.
       allocation_begin = mallinfo();
     }
 

Reply via email to