[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#247436: libc6-dev: odd dev_t/varargs behavior



Package: libc6-dev
Version: 2.3.2.ds1-12
Severity: normal

I'm seeing some very odd behavior with dev_t (defined in linux/kdev_t.h)
and varargs.  I have the following source file:

#include <stdio.h>
#include <sys/types.h>
#include <linux/kdev_t.h>
                                                                                
int main(void)
{
        dev_t x = 0x3af;
        printf("%x %x\n", ((x)>>8), ((x)&0xff));
        return 0;
}


One would think that this would print out "3 af"; however, it displays
"3 0".  If I change that printf to:
	printf("%x %x %x\n", ((x)>>8), ((x)&0xff));
I get "3 0 af".  It would appear that dev_t, when passed as to a vararg
function, adds an additional argument as padding.  So, when I pass "x>>8",
what printf() sees is "x>>8, 0".  This doesn't happen normally; if I
change the definition of x to:
	unsigned int x = 0x3af;
I get "3 af".  Also, if I explicitly cast the args to unsigned int:
        printf("%x %x\n", (unsigned int) ((x)>>8), (unsigned int) ((x)&0xff));
I get "3 af".  So, it's some weird handling of dev_t's.


... I'm not quite sure what to make of it.  I _think_ it's a glibc
problem..
 



-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.5-1-686
Locale: LANG=C, LC_CTYPE=C

Versions of packages libc6-dev depends on:
ii  libc6                2.3.2.ds1-12        GNU C Library: Shared libraries an
ii  linux-kernel-headers 2.5.999-test7-bk-15 Linux Kernel Headers for developme

-- no debconf information



Reply to: