This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
__builtin_va_list bug ir feature
- From: "Gisle Vanem" <gvanem at eunet dot no>
- To: <gcc at gcc dot gnu dot org>
- Date: Fri, 25 Apr 2003 16:16:53 +0200
- Subject: __builtin_va_list bug ir feature
gcc -v
Reading specs from e:/djgpp/lib/gcc-lib/djgpp/3.22/specs
Configured with: /dj204/gnu/gcc-3.22/configure i586-pc-msdosdjgpp
--prefix=/dev/env/DJDIR --disable-nls
Thread model: single
gcc version 3.2.2
I'm porting some code from Watcom to gcc 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)
{
x = va_arg (arg, char);
}
This gives a warning "`char' is promoted to `int' when passed through `...'"
Fair enough, but when I produce an asm-listing, here's what I get:
.file "test.c"
.section .text
.globl _foo
_foo:
pushl %ebp
movl %esp, %ebp
int $5 # <<<<
.comm _x,16
.ident "GCC: (GNU) 3.2.2"
What's the "int $5" doing there?
Is this a gcc bug or feature? I found absolutely nothing in the
gcc online docs about this. If it's a feature, what's the rationale
behind it? IMHO if gcc should treat this as a fatal error instead
of emitting a bound trap (int $5). That is just too nasty. I spent
a full day tracking this down.
Using "va_arg (arg,int)" of-course produces the correct code.
--gv