https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79691
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic,
| |missed-optimization
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2017-02-23
CC| |msebor at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot
gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed for the missing diagnostic
(https://gcc.gnu.org/ml/gcc/2017-02/msg00105.html).
It's a also a missed optimization because, as can be seen in the test case
below, the sprintf return value optimization isn't done:
$ (set -x && cat t.c && for O in 1 g; do gcc -O$O -S -Wall -Wextra -Wpedantic
-fdump-tree-optimized=/dev/stdout t.c; done)
+ cat t.c
int f (void)
{
return __builtin_snprintf (0, 0, "%i", 123);
}
+ for O in 1 g
+ gcc -O1 -S -Wall -Wextra -Wpedantic -fdump-tree-optimized=/dev/stdout t.c
;; Function f (f, funcdef_no=0, decl_uid=1795, cgraph_uid=0, symbol_order=0)
f ()
{
<bb 2> [100.00%]:
return 3;
}
+ for O in 1 g
+ gcc -Og -S -Wall -Wextra -Wpedantic -fdump-tree-optimized=/dev/stdout t.c
;; Function f (f, funcdef_no=0, decl_uid=1795, cgraph_uid=0, symbol_order=0)
f ()
{
int _3;
<bb 2> [100.00%]:
_3 = __builtin_snprintf (0B, 0, "%i", 123);
return _3;
}