Re: Problems with using identifier long long int in gcc++

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

 



On Thursday 29 November 2007 17:01, Maxim Areshkau wrote:
> l1: unsigned long long a;
> l2: cout << sizeof(a) << endl;
> l3: a = 1281474976710655;
> l4: cout << a << endl;
> When we trying to compile such code with gcc++, it's throw error that
> the  constant '1281474976710655' is too large for long long, it is only

An decimal integer literal without suffix has either type int or long int. If 
the value can not be represented as long int, the behavior is undefined 
(which is bad thing). As Maxim wrote, add ULL to the literal.

> 2**48-1, when max number for unsigned long long is 2**64. This code
> compiles normal when we use Microsoft  compiler.

Undefined Behavior: gcc gives you an clear error message, Microsoft tries to 
"fix it".


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux