va_arg regression from 2.95.2 to 3.1
Schirmer, Hartmut
HSchirmer@Innovative-Systems.de
Wed Mar 27 00:41:00 GMT 2002
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;
}
More information about the Gcc-bugs
mailing list