delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/04/20/11:01:34

Message-ID: <3EA26C19.81D82449@acm.org>
From: Eric Sosman <esosman AT acm DOT org>
X-Mailer: Mozilla 4.72 [en] (Win95; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: __builtin_va_list bug?
References: <0ab801c306bf$4dacb430$0600000a AT broadpark DOT no>
Lines: 26
Date: Sun, 20 Apr 2003 14:44:30 GMT
NNTP-Posting-Host: 12.91.3.234
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1050849870 12.91.3.234 (Sun, 20 Apr 2003 14:44:30 GMT)
NNTP-Posting-Date: Sun, 20 Apr 2003 14:44:30 GMT
Organization: AT&T Worldnet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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.

>   x = va_arg (arg, char);

    This will be wrong with either <stdarg.h> or <varargs.h>, since
the actual type of the parameter is not `char' but whatever `char'
gets promoted to: `int' on most machines, but perhaps `unsigned int'
on some oddball architectures.  You must specify the promoted type,
not the type to which you will later "demote" it.

-- 
Eric Sosman
esosman AT acm DOT org

- Raw text -


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