Bug#204580: g++: unexpected output using variadic functions in classes
"Frank B. Brokken" <f.b.brokken@rc.rug.nl> writes:
> class Foo
> {
> va_list list;
>
> public:
> Foo(int n, ...)
> {
> va_start(list, n);
> }
> Foo(Foo const &other)
> {
> va_copy(list, other.list);
> }
> ~Foo()
> {
> va_end(list);
> }
> void bar() const
> {
> va_list l(list);
> cout << "Saw " << va_arg(l, int) << endl;
> }
> };
This is still invalid, since va_end is not in the same function as
va_start.
I suspect that it is simply not possible to do what you want, since,
after all, the va_list does not actually contain a copy of all passed
parameters, but is basically just a pointer into the stack.
--
Falk
Reply to: