[Bug tree-optimization/78476] snprintf(0, 0, ...) with known arguments not optimized away
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Nov 22 23:59:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78476
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2016-11-22
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
The test in comment #0 isn't quite right. The result of the snprintf call
isn't 7 but rather at most 7 so the call cannot be easily eliminated. The
following is a test case where the call can be, and with the attached patch is,
eliminated.
void f (void)
{
int n = 7;
const char *s = "1234567";
if (n != __builtin_snprintf (0, 0, "%.*s", n, s))
__builtin_abort ();
}
More information about the Gcc-bugs
mailing list