Variadic Function Arguments Lifetime

Get to learn about the lifetime of variadic function arguments.

The short lifetime of variadic function arguments

The slice argument that is automatically generated for a variadic parameter points at a temporary array that has a short lifetime. This does not matter if the function uses the arguments only during its execution. However, it becomes a bug if the function keeps a slice in those elements for later use:

svg viewer

Get hands-on with 1200+ tech skills courses.