This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/79697] unused realloc(0, n) not eliminated
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Feb 2017 00:23:37 +0000
- Subject: [Bug tree-optimization/79697] unused realloc(0, n) not eliminated
- Auto-submitted: auto-generated
- References: <bug-79697-4@http.gcc.gnu.org/bugzilla/>
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;
}