Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 155998 - printf does the wrong thing when given a 64-bit long
Summary: printf does the wrong thing when given a 64-bit long
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-22 22:30 UTC by David Geib
Modified: 2006-11-26 07:19 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Geib 2006-11-22 22:30:17 UTC
david@localhost ~ $ cat test64.c
#include<stdio.h>

int main()
{
        long i = 0x0123456789abcdef;
        printf("%d bit long: %x\n", 8*sizeof(i), i);
}
david@localhost ~ $ gcc test64.c -o test64
david@localhost ~ $ ./test64
64 bit long: 89abcdef
Comment 1 SpanKY gentoo-dev 2006-11-26 07:16:53 UTC
has nothing to do with coreutils afaict
Comment 2 SpanKY gentoo-dev 2006-11-26 07:19:31 UTC
you should really build with warnings enabled (-Wall)

then you should read the printf(3) manpage

%x takes an unsigned int and since you did not include any length modifiers, printf() only shows (unsigned int)(0x0123456789abcdef) which correctly evaluates to 0x89abcdef