Title
cstdarg and unnamed parameters
Status
nad
Section
[support.exception]
Submitter
J. Stephen Adamczyk

Created on 2000-10-10.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

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.

Date: 2000-10-10.00:00:00

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:33adminsetmessages: + msg2062
2000-10-10 00:00:00admincreate