delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/04/20/13:16:38

From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: __builtin_va_list bug?
Date: Sun, 20 Apr 2003 16:12:17 +0100
Lines: 48
Message-ID: <3EA2B8D1.643143D4@phekda.freeserve.co.uk>
References: <0ab801c306bf$4dacb430$0600000a AT broadpark DOT no> <3EA26C19 DOT 81D82449 AT acm DOT org>
NNTP-Posting-Host: 62.136.14.148
Mime-Version: 1.0
X-Trace: newsg2.svr.pol.co.uk 1050858147 11481 62.136.14.148 (20 Apr 2003 17:02:27 GMT)
NNTP-Posting-Date: 20 Apr 2003 17:02:27 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello.

Eric Sosman wrote:
> 
> Gisle Vanem wrote:
> >
> > I'm porting some code from Watcom to gcc/djgpp and encountered
> > tons of warnings on illegal use of va_arg(). So I cooked up a little
> > test:
> >
> > #include <stdarg.h>
> > char x;
> > void foo (va_list arg)
> 
>     Hold on; stop right there.  You've included <stdarg.h>, but you're
> using the argument list declaration from the pre-Standard <varargs.h>
> (or <vararg.h> with some compilers).  The two are not the same, they
> are not interchangeable, and they are *definitely* not miscible.
[snip]

Are you sure that's happening? What if some function calls foo like this:

void
myfunc (int someval, ...)
{
  va_list arg;

  va_start(arg, someval);
  foo(arg);
  va_end(arg);
}

I think this is legal according to the C99 standard. From section 7.15
"Variable arguments <stdarg.h>":

"The object ap may be passed as an argument to
another function; if that function invokes the va_arg macro with parameter ap,
the
value of ap in the calling function is indeterminate and shall be passed to
the va_end
macro prior to any further reference to ap."

ap is the va_list - i.e.: arg in the function myfunc above.

Regards,

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019