[Bug tree-optimization/88814] transform snprintf into memccpy

2024-06-23 Thread crrodriguez at opensuse dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88814

--- Comment #4 from Cristian Rodríguez  ---
Any hope to revive this now that memccpy is on the C23 standard?

[Bug tree-optimization/88814] transform snprintf into memccpy

2020-08-24 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88814

--- Comment #3 from Martin Sebor  ---
(In reply to Dávid Bolvanský from comment #2)

The n in the assignment in 'd[n - 1] = 0;' should be the result of snprintf for
constant arguments.  In GCC, it's computed by the sprintf pass which then
performs other substitutions based on it.

[Bug tree-optimization/88814] transform snprintf into memccpy

2019-10-02 Thread david.bolvansky at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88814

Dávid Bolvanský  changed:

   What|Removed |Added

 CC||david.bolvansky at gmail dot 
com

--- Comment #2 from Dávid Bolvanský  ---
You cannot [0] do this general transformation..

Runtime variable n = 10.

d[9] = 'A';
snprintf(d, n, "%s", s) // s is "str"
assert(d[9] == 'A');
=>
d[9] = 'A';
memccpy(d, s, 0, 9);
d[9] = 0;
assert(d[9] == 'A');

[0] https://reviews.llvm.org/D67986

[Bug tree-optimization/88814] transform snprintf into memccpy

2019-05-24 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88814

Martin Sebor  changed:

   What|Removed |Added

   See Also|https://gcc.gnu.org/bugzill |
   |a/show_bug.cgi?id=90263 |

--- Comment #1 from Martin Sebor  ---
The proposal to add memccpy to C2X was approved in WG14 last month so once
__builtin_memccpy is implemented the transformation can be added.

 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2349.htm