[RTEMS Project] #4662: Fix GCC 12 warnings

RTEMS trac trac at rtems.org
Wed Aug 3 07:44:09 UTC 2022


#4662: Fix GCC 12 warnings
-------------------------+---------------------
 Reporter:  Chris Johns  |       Owner:  (none)
     Type:  defect       |      Status:  new
 Priority:  normal       |   Milestone:  6.1
Component:  tool/gcc     |     Version:  6
 Severity:  blocker      |  Resolution:
 Keywords:               |  Blocked By:
 Blocking:               |
-------------------------+---------------------

Comment (by Chris Johns):

 This warning looks like a bug in our heap allocator:
 {{{
 ../../../testsuites/libtests/malloctest/init.c: In function
 'test_early_malloc':
 |
 |
 ../../../testsuites/libtests/malloctest/init.c:1531:7: warning: pointer
 'q' used after 'free' [-Wuse-after-free]
 |  r = realloc( q, 128 );
 |/**
  1531 |   r = realloc( q, 128 );
 |  rtems_test_assert( r == q );
 |-=--:----F1  libio_.h       12% (110,15)  Git-master  (C++//l Abbrev)
 [ruru]
 ------------------------------------------------------------------------------------------------------------------------
       |       ^~~~~~~~~~~~~~~~~
 |
 | * defined state even if no root file system was mounted.
 ../../../testsuites/libtests/malloctest/init.c:1529:3: note: call to
 'free' here
 |  s = malloc( 1 );
 | */
  1529 |   free( q );
 |  rtems_test_assert( s != NULL );
 |extern rtems_filesystem_global_location_t
 rtems_filesystem_global_location_null;
       |   ^~~~~~~~~
 |
 |
 }}}
 The pointer `q` has been free so I am wondering if the `realloc` works
 because the same block in the heap is allocated?

--
Ticket URL: <http://devel.rtems.org/ticket/4662#comment:8>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list