Created on 2000-10-10.00:00:00 last changed 172 months ago
Rationale:
Not a defect, the C and C++ standards are clear. It is impossible to use varargs if the parameter immediately before "..." has no name, because that is the parameter that must be passed to va_start. The example given above is broken, because va_start is being passed the wrong parameter.
There is no support for extending varargs to provide additional functionality beyond what's currently there. For reasons of C/C++ compatibility, it is especially important not to make gratuitous changes in this part of the C++ standard. The C committee has already been requested not to touch this part of the C standard unless necessary.
One of our customers asks whether this is valid C++:
#include <cstdarg> void bar(const char *, va_list); void foo(const char *file, const char *, ...) { va_list ap; va_start(ap, file); bar(file, ap); va_end(ap); }
The issue being whether it is valid to use cstdarg when the final parameter before the "..." is unnamed. cstdarg is, as far as I can tell, inherited verbatim from the C standard. and the definition there (7.8.1.1 in the ISO C89 standard) refers to "the identifier of the rightmost parameter". What happens when there is no such identifier?
My personal opinion is that this should be allowed, but some tweak might be required in the C++ standard.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg2062 |
2000-10-10 00:00:00 | admin | create |