help-gplusplus
[Top][All Lists]
Advanced

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

Re: G++ optimization bug?


From: Ulrich Eckhardt
Subject: Re: G++ optimization bug?
Date: Sat, 07 Apr 2007 10:33:16 +0200
User-agent: KNode/0.10.4

Larry Smith wrote:
>     // hmmm, pointers on 64 bit hdw are 'long',
>     // not 'long long'.
>     // int is 32 bits, long is 64 bits, ptr is
>     // 64 bits.

Sorry, but that is not universally true. You can be reasonably sure that a
pointer has the same size as a size_t or a ptrdiff_t, but other than that
all bets are off. Now, the LLP64 model makes the long long and pointers 64
bits, while long stays 32 bits. The LP64 model uses 64 bit long and
pointers, which is what Linux uses on 64 bit hardware.

>   printf("%u = sizeof int\n", sizeof(int) );
>   printf("%u = sizeof long\n", sizeof(long) );
>   printf("%u = sizeof ptr\n", sizeof(void *) );
>   printf("%u = sizeof long long\n", sizeof(long long) );

FYI: with 64 bit size_t and 32 bit unsigned, you have a mismatch between
the printf arguments and its format string. Did you compile with any
warnings?

Uli

-- 
http://gcc.gnu.org/faq.html
http://parashift.com/c++-faq-lite/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]