https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79696

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|2017-07-31 00:00:00         |2017-10-31
     Ever confirmed|0                           |1

--- Comment #4 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #3)
> Whoops.  The test case is below.  Also, the calls to the functions are only
> eliminated with optimization.  Otherwise they're emitted and the leaks
> allowed to go undetected.  (For some reason I don't understand, Glibc only
> also marks functions warn_unused_result with _FORTIFY_SOURCE, otherwise its
> __wur macro that's used for this purpose expands to nothing.)
> 
> $ cat a.c && gcc -S -Wall -Wextra -Wpedantic
> -fdump-tree-optimized=/dev/stdout a.c
> void f (unsigned n)
> {
>   __builtin_malloc (n);
> }
> 
> void g (unsigned n)
> {
>   __builtin_calloc (n, n);
> }
> 
> void h (unsigned n)
> {
>   __builtin_aligned_alloc (n, 2);
> }
> 
> ;; Function f (f, funcdef_no=2, decl_uid=2364, cgraph_uid=2, symbol_order=2)
> 
> f (unsigned int n)
> {
>   long unsigned int _1;
> 
>   <bb 2> [0.00%] [count: INV]:
>   _1 = (long unsigned int) n_2(D);
>   __builtin_malloc (_1);
>   return;
> 
> }
> 
> 
> 
> ;; Function g (g, funcdef_no=3, decl_uid=2367, cgraph_uid=3, symbol_order=3)
> 
> g (unsigned int n)
> {
>   long unsigned int _1;
>   long unsigned int _2;
> 
>   <bb 2> [0.00%] [count: INV]:
>   _1 = (long unsigned int) n_3(D);
>   _2 = (long unsigned int) n_3(D);
>   __builtin_calloc (_2, _1);
>   return;
> 
> }
> 
> 
> 
> ;; Function h (h, funcdef_no=4, decl_uid=2370, cgraph_uid=4, symbol_order=4)
> 
> h (unsigned int n)
> {
>   long unsigned int _1;
> 
>   <bb 2> [0.00%] [count: INV]:
>   _1 = (long unsigned int) n_2(D);
>   __builtin_aligned_alloc (_1, 2);
>   return;
> 
> }

Confirmed, although the optimized output is slightly different for me:

$ /usr/local/bin/gcc -c -S -Wall -Wextra -Wpedantic
-fdump-tree-optimized=/dev/stdout 79696.c

;; Function f (f, funcdef_no=0, decl_uid=1769, cgraph_uid=0, symbol_order=0)

f (unsigned int n)
{
  <bb 2> [0.00%] [count: INV]:
  __builtin_malloc (n_2(D));
  return;

}



;; Function g (g, funcdef_no=1, decl_uid=1772, cgraph_uid=1, symbol_order=1)

g (unsigned int n)
{
  <bb 2> [0.00%] [count: INV]:
  __builtin_calloc (n_2(D), n_2(D));
  return;

}



;; Function h (h, funcdef_no=2, decl_uid=1775, cgraph_uid=2, symbol_order=2)

h (unsigned int n)
{
  <bb 2> [0.00%] [count: INV]:
  __builtin_aligned_alloc (n_2(D), 2);
  return;

}


$

Reply via email to