This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
va_arg regression from 2.95.2 to 3.1
- From: "Schirmer, Hartmut" <HSchirmer at Innovative-Systems dot de>
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Date: Wed, 27 Mar 2002 09:25:44 +0100
- Subject: va_arg regression from 2.95.2 to 3.1
Hi,
the attached test cases works fine on
2.95.2 (sh-hitachi-coff)
but fails to compile using
Reading specs from /gcc-3.1-sh-elf/lib/gcc-lib/sh-elf/3.1/specs
Configured with: ../gcc-20020325/configure --verbose --target=sh-elf
--host=i586-pc-cygwin --prefix=
/gcc-3.1-sh-elf --enable-haifa --enable-languages=c,c++
Thread model: single
gcc version 3.1 20020325 (prerelease)
Output is:
gcc31va.c:6: warning: no previous declaration for `foo'
gcc31va.c: In function `foo':
gcc31va.c:14: `int16' is promoted to `int' when passed through `...'
gcc31va.c:14: (so you should pass `int' not `int16' to `va_arg')
Since
res = va_arg(ap,int16);
will never be executed the compiler shouldn't give
an error.
Is there any other way to get varguments of unknown size
through va_arg ?
Thanks,
Hartmut
#include <stdarg.h>
#include <stddef.h>
typedef short int16;
int foo(int x, ...)
{
int res;
va_list ap;
va_start(ap,x);
if ( sizeof(int16) < sizeof(int) )
res = va_arg(ap,int);
else
res = va_arg(ap,int16);
va_end(ap);
return res;
}