This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc va_arg processing bug on i686-cygwin
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- To: "Sergey Okhapkin" <sos at sokhapkin dot dyndns dot org>,"Christopher Faylor" <cgf at redhat dot com>,<gcc-bugs at gcc dot gnu dot org>
- Date: Fri, 27 Dec 2002 17:39:51 +0100
- Subject: Re: gcc va_arg processing bug on i686-cygwin
- References: <004001c2ac8b$027bbad0$0201a8c0@sos> <20021226040301.GB6101@redhat.com> <005f01c2aceb$25210c10$0201a8c0@sos>
On Thursday 26 December 2002 15:29, Sergey Okhapkin wrote:
> Gcc generates incorrect assembly code while processing "va_arg(ap, char)".
> I just built gcc from today's CVS snapshot and got the same error with
>
> E:\obj\cygwin32\gcc>gcc -v
> Reading specs from /bin/../lib/gcc-lib/i686-pc-cygwin/3.4/specs
> Configured with:
> /usr/src/cygnus/gcc/configure --enable-libgcj --enable-threads=
> posix --with-system-zlib --enable-nls --without-included-gettext
> --enable-in terp
> reter --disable-sjlj-exceptions --disable-version-specific-runtime-libs
> --en able
> -shared --enable-haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc
> -- libd
> ir=/usr/lib --includedir=/nonexistent/include --libexecdir=/usr/sbin -v :
> (recon
> figured)
> /usr/src/cygnus/gcc/configure --with-gcc-version-trigger=/usr/src/cygnu
> s/gcc/gcc/version.c --host=i686-pc-cygwin --enable-libgcj
> --enable-threads=p osix
> --with-system-zlib --enable-nls --without-included-gettext
> --enable-interpr eter
> --disable-sjlj-exceptions --disable-version-specific-runtime-libs
> --enable- shar
> ed --enable-haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc
> --libdi r=/u
> sr/lib --libexecdir=/usr/sbin -v : (reconfigured) : (reconfigured) :
> (reconfig
> ured)
> Thread model: posix
> gcc version 3.4 20021226 (experimental)
>
> Sergey Okhapkin
> Somerset, NJ
> ----- Original Message -----
> From: "Christopher Faylor" <cgf@redhat.com>
> To: "Sergey Okhapkin" <sos@sokhapkin.dyndns.org>
> Sent: Wednesday, December 25, 2002 11:03 PM
> Subject: Re: gcc bug?
>
> > On Wed, Dec 25, 2002 at 10:00:55PM -0500, Sergey Okhapkin wrote:
> > >gcc version 3.2 20020927 (prerelease)
> > >
> > >E:\usr\src\tests>cat va.c
> > >#include <stdarg.h>
> > >
> > >static char c_saved;
> > >static int i_saved;
> > >
> > >void sv_exp(char *format, ...)
> > >{
> > > va_list ap;
> > >
> > > va_start(ap, format);
> > > c_saved = va_arg(ap, char);
> > > va_end(ap);
> > > va_start(ap, format);
> > > i_saved = va_arg(ap, int);
> > > va_end(ap);
> > >
> > > return;
> > >}
> > >
> > >E:\usr\src\tests>gcc -S va.c
> > >va.c: In function `sv_exp':
> > >va.c:11: warning: `char' is promoted to `int' when passed through `...'
> > >va.c:11: warning: (so you should pass `int' not `char' to `va_arg')
Fix this warning (eg use "(char) va_arg(ap,int)" and you will be happy. GCC is
correct in producing an "int 5" (I assume it's something like an abort on you
platform) here, it's just a result of the invalid C code that a
runtime abort is generated here.
Franz.