Date: Tue, 20 Jan 1998 19:33:18 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: current@freebsd.org Subject: Nasty GCC bug? Message-ID: <199801201933.MAA27126@usr04.primenet.com>
next in thread | raw e-mail | index | archive | help
I have discovered what I think is a nasty bug, having to do with passing signed smaller-than-int values to varradic functions. #include <stdio.h> /* * demonstrate bug with signed smaller-than-int arguments to * varradic functions... */ main() { short ss = 0xebeb; unsigned short us = 0xebeb; char sc = 0xeb; unsigned char uc = 0xeb; printf( "Expecting 0x%04x, but getting 0x%04x\n", us, ss); printf( "Expecting 0x%02x, but getting 0x%02x\n", uc, sc); } What is happening is that the value is being sign-extended to int when it is pushed on the stack. I don't know how you would make "%d" and "%x" work at the same time, without a type descriptor on the stack before the argument. Maybe there needs to be a character type specifier for "%x"? Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801201933.MAA27126>