This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/79697] unused realloc(0, n) not eliminated


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

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Ditto for __builtin_strdup and __builtin_strndup.  Both of those calls can (and
arguably should) be eliminated.  If they're not eliminated (but even if they
are) a warning on them can and arguably should be issued as suggested in bug
79696.

Clang 5.0 eliminates both of the calls but doesn't issue a warning.  Clang does
not, however, eliminate the unused call to realloc in the test case in comment
#1.

$ cat t.c && gcc -O2 -S -Wall -Wextra -Wpedantic -Wunused-result
-fdump-tree-optimized=/dev/stdout t.c
void f (void)
{
  __builtin_strdup ("abc");
}

void g (void)
{
  __builtin_strndup ("abc", 2);
}


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

f ()
{
  <bb 2> [100.00%]:
  __builtin_strdup ("abc"); [tail call]
  return;

}



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

g ()
{
  <bb 2> [100.00%]:
  __builtin_strndup ("abc", 2); [tail call]
  return;

}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]