public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 3.3: long long bug?
@ 2003-04-07 11:29 Lev Assinovsky
  2003-04-07 11:42 ` Eric Botcazou
  0 siblings, 1 reply; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 11:29 UTC (permalink / raw)
  To: gcc-bugs, gcc-help

Hi all!
Took gcc-20030331 snap.
Compile max.cpp:

const long long n = 34359738368; // 2^35

Got:
max.cpp:1: error: integer constant is too large for "long" type

gcc3.2 doesn't give any errors.

Is that an error of gcc 3.3 or mine?

Thanks, 
----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: gcc 3.3: long long bug?
@ 2003-04-07 13:08 Lev Assinovsky
  2003-04-07 13:13 ` A.R. Ashok Kumar
  0 siblings, 1 reply; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 13:08 UTC (permalink / raw)
  To: A.R. Ashok Kumar, Andreas Schwab; +Cc: Eric Botcazou, gcc-help

No, sizeof (long long) is 8 in my system.

----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909


> -----Original Message-----
> From: A.R. Ashok Kumar [mailto:ashokar@sankhya.com]
> Sent: Monday, April 07, 2003 4:30 PM
> To: Andreas Schwab
> Cc: Eric Botcazou; Lev Assinovsky; gcc-help@gcc.gnu.org
> Subject: Re: gcc 3.3: long long bug?
> 
> 
> Hi,
> 
> > |> > const long long n = 34359738368; // 2^35
> > |> >
> > |> > Got:
> > |> > max.cpp:1: error: integer constant is too large for "long" type
> > |> 
> > |> Append "LL" to the constant.
> > 
> > That should not be needed.
> 
>    Size for type "long long" may be only 32-bit in your 
> system. Since it
>    is 35-bit number, it gives error.
> 
>    You can check the size of "long long" type in your system, 
> by printing
>    sizeof(long long). 
> 
> Best Wishes,
> AshokA
> 
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: gcc 3.3: long long bug?
@ 2003-04-07 13:13 Lev Assinovsky
  2003-04-07 13:43 ` A.R. Ashok Kumar
  0 siblings, 1 reply; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 13:13 UTC (permalink / raw)
  To: John Love-Jensen, Andreas Schwab, Eric Botcazou; +Cc: gcc-bugs, gcc-help

I think gcc 3.2 (which didn't give me any errors)
behaves more properly, automatically converting 
rvalue to lvalue. Such behavior also solves
"long long long ..." problems.

----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909


> -----Original Message-----
> From: John Love-Jensen [mailto:eljay@adobe.com]
> Sent: Monday, April 07, 2003 5:01 PM
> To: Andreas Schwab; Eric Botcazou
> Cc: Lev Assinovsky; gcc-bugs@gcc.gnu.org; gcc-help@gcc.gnu.org
> Subject: Re: gcc 3.3: long long bug?
> 
> 
> Hi Andreas,
> 
> > |> Append "LL" to the constant.
> > 
> > That should not be needed.
> 
> The "LL" should be needed, unless a "long long" is the same size as a
> "long".
> 
> The "long long" data type is an extension to the C (ISO 9989) 
> and C++ (ISO
> 14882) specs.  As such, automatically sizing a numeric 
> literal to "long
> long" (like how a numeric literal that's too big for an "int" 
> becomes an
> "unsigned int", and then a "long" and then an "unsigned 
> long") could cause
> problems.
> 
> Unfortunately, requiring the "LL" suffix causes other headaches.
> 
> I wonder when we'll have "long long long" (128-bit) and "long 
> long long
> long" (256-bit) numbers.  With accompanying "LLL" and "LLLL" suffixes.
> *sigh*
> 
> --Eljay
> 
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: gcc 3.3: long long bug?
@ 2003-04-07 13:15 Lev Assinovsky
  0 siblings, 0 replies; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 13:15 UTC (permalink / raw)
  To: A.R. Ashok Kumar, Andreas Schwab; +Cc: Eric Botcazou, gcc-help

8 bytes = 64 bits.
I have UltraSpars 64 bits.

----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909


> -----Original Message-----
> From: A.R. Ashok Kumar [mailto:ashokar@sankhya.com]
> Sent: Monday, April 07, 2003 5:07 PM
> To: Andreas Schwab
> Cc: Eric Botcazou; Lev Assinovsky; gcc-help@gcc.gnu.org
> Subject: Re: gcc 3.3: long long bug?
> 
> 
> Hi,
> 
> > |>    You can check the size of "long long" type in your 
> system, by printing
> > |>    sizeof(long long). 
> > 
> > On my system sizeof(long) is 8.
> 
>   Since 8 bytes are too small to hold 35-bit numbers, the 
> error occurred.
> 
>   Please use 'LL' suffix, to solve the problem.
> 
>    i.e  const long long n = 34359738368LL;
> 
> - AshokA -
> 
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: gcc 3.3: long long bug?
@ 2003-04-07 13:33 Lev Assinovsky
  0 siblings, 0 replies; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 13:33 UTC (permalink / raw)
  To: A.R. Ashok Kumar
  Cc: John Love-Jensen, Andreas Schwab, Eric Botcazou, gcc-bugs, gcc-help

#include <iostream>
using namespace std;
const long long n = 34359738368LL; // 2^35
 
int main()
{
    cout << "Printed:" << n << endl;
}

Printed:34359738368

----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909


> -----Original Message-----
> From: A.R. Ashok Kumar [mailto:ashokar@sankhya.com]
> Sent: Monday, April 07, 2003 5:26 PM
> To: Lev Assinovsky
> Cc: John Love-Jensen; Andreas Schwab; Eric Botcazou;
> gcc-bugs@gcc.gnu.org; gcc-help@gcc.gnu.org
> Subject: RE: gcc 3.3: long long bug?
> 
> 
> Hi,
> 
> > I think gcc 3.2 (which didn't give me any errors)
> > behaves more properly, automatically converting 
> > rvalue to lvalue. Such behavior also solves
> > "long long long ..." problems.
> 
>   Have you obtained correct result? 
> 
>   For me, the following program gives wrong result(using gcc 2.7.2 on
>   sparc-sun-solaris2.3).
> 
> ------
> const long long n = 34359738368LL;
> int  main() {
>         printf("%ld\n", n);
> }
> ------
> 
>  Obtained Result: 8
>  Expected Result: 34359738368
> 
> - AshokA-
> 
> > > -----Original Message-----
> > > From: John Love-Jensen [mailto:eljay@adobe.com]
> > > Sent: Monday, April 07, 2003 5:01 PM
> > > To: Andreas Schwab; Eric Botcazou
> > > Cc: Lev Assinovsky; gcc-bugs@gcc.gnu.org; gcc-help@gcc.gnu.org
> > > Subject: Re: gcc 3.3: long long bug?
> > > 
> > > 
> > > Hi Andreas,
> > > 
> > > > |> Append "LL" to the constant.
> > > > 
> > > > That should not be needed.
> > > 
> > > The "LL" should be needed, unless a "long long" is the 
> same size as a
> > > "long".
> > > 
> > > The "long long" data type is an extension to the C (ISO 9989) 
> > > and C++ (ISO
> > > 14882) specs.  As such, automatically sizing a numeric 
> > > literal to "long
> > > long" (like how a numeric literal that's too big for an "int" 
> > > becomes an
> > > "unsigned int", and then a "long" and then an "unsigned 
> > > long") could cause
> > > problems.
> > > 
> > > Unfortunately, requiring the "LL" suffix causes other headaches.
> > > 
> > > I wonder when we'll have "long long long" (128-bit) and "long 
> > > long long
> > > long" (256-bit) numbers.  With accompanying "LLL" and 
> "LLLL" suffixes.
> > > *sigh*
> > > 
> > > --Eljay
> > > 
> > > 
> > 
> 
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: gcc 3.3: long long bug?
@ 2003-04-07 13:43 Lev Assinovsky
  2003-04-07 13:36 ` A.R. Ashok Kumar
  2003-04-07 20:22 ` Ben Davis
  0 siblings, 2 replies; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 13:43 UTC (permalink / raw)
  To: A.R. Ashok Kumar, Andreas Schwab; +Cc: Eric Botcazou, gcc-help

No, what was the reason to change the behavior of 3.2?
We developing the portable application which should work
in Windows 2000 also.
There is an automatic recognition of long long constants in MSVC though you can 
add i64 suffix.
With 3.3 I have to write:
const long long n =
#ifdef WIN32
34359738368
#else
34359738368LL
#endif
;

Not nice, right?

----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909


> -----Original Message-----
> From: A.R. Ashok Kumar [mailto:ashokar@sankhya.com]
> Sent: Monday, April 07, 2003 5:17 PM
> To: Andreas Schwab
> Cc: Eric Botcazou; Lev Assinovsky; gcc-help@gcc.gnu.org
> Subject: Re: gcc 3.3: long long bug?
> 
> 
> Hi,
> 
> > |> > |>    You can check the size of "long long" type in 
> your system, by printing
> > |> > |>    sizeof(long long). 
> > |> > 
> > |> > On my system sizeof(long) is 8.
> > |> 
> > |>   Since 8 bytes are too small to hold 35-bit numbers, 
> the error occurred.
> > 
> > ??? 8*8 = 64.
> 
>   Yes, It should work for 35-bit numbers
> 
> - Ashok -
> 
> > Andreas Schwab, SuSE Labs, schwab@suse.de
> > SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 NЭrnberg
> > Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> > "And now for something completely different."
> > 
> 
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: gcc 3.3: long long bug?
@ 2003-04-07 13:43 Lev Assinovsky
  2003-04-07 14:12 ` Andreas Schwab
  0 siblings, 1 reply; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 13:43 UTC (permalink / raw)
  To: A.R. Ashok Kumar; +Cc: Andreas Schwab, Eric Botcazou, gcc-help

No I meant MSVC 6.2 on Windows.
Yes, it works without any suffixes 
with 3.2 on Unix.
Also this:
const long long n =  100000000 * 1000000000;

works with 3.3 on Unix either. 

----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909


> -----Original Message-----
> From: A.R. Ashok Kumar [mailto:ashokar@sankhya.com]
> Sent: Monday, April 07, 2003 5:35 PM
> To: Lev Assinovsky
> Cc: Andreas Schwab; Eric Botcazou; gcc-help@gcc.gnu.org
> Subject: RE: gcc 3.3: long long bug?
> 
> 
> Hi,
> 
> > No, what was the reason to change the behavior of 3.2?
> > We developing the portable application which should work
> > in Windows 2000 also.
> > There is an automatic recognition of long long constants in 
> MSVC though you can 
> > add i64 suffix.
> > With 3.3 I have to write:
> > const long long n =
> > #ifdef WIN32
> > 34359738368
> > #else
> > 34359738368LL
> > #endif
> > ;
> > 
> > Not nice, right?
> 
>   Is gcc3.3 for Win32 gives error for the following statement?
> 
>     const long long n = 34359738368LL;
> 
>   If so, it is not nice behaviour. Does it work for gcc 3.2 ?
> 
> - AshokA -
> 
> 
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: gcc 3.3: long long bug?
@ 2003-04-07 14:41 Lev Assinovsky
  2003-04-07 14:58 ` Andreas Schwab
  0 siblings, 1 reply; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 14:41 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: A.R. Ashok Kumar, Eric Botcazou, gcc-help

100000000 * 1000000000 is calculated during compilation, right?
So the compiler is able to manage long long constants internally.
I guess all this issue occurs because of new gcc 3.3 parser 
where long long literals are not recognized properly unless
"LL" suffix is presented.
May be I am wrong. May be there are another explanations 
of the different long long processing in 3.3 vs. 3.2.
----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909


> -----Original Message-----
> From: Andreas Schwab [mailto:schwab@suse.de]
> Sent: Monday, April 07, 2003 6:13 PM
> To: Lev Assinovsky
> Cc: A.R. Ashok Kumar; Eric Botcazou; gcc-help@gcc.gnu.org
> Subject: Re: gcc 3.3: long long bug?
> 
> 
> "Lev Assinovsky" <LAssinovsky@algorithm.aelita.com> writes:
> 
> |> No I meant MSVC 6.2 on Windows.
> |> Yes, it works without any suffixes 
> |> with 3.2 on Unix.
> |> Also this:
> |> const long long n =  100000000 * 1000000000;
> |> 
> |> works with 3.3 on Unix either. 
> 
> Whatever you mean with "works".  This is invoking undefined 
> behaviour if
> LONG_MAX < 100000000000000000, or INT_MAX >= 1000000000 and INT_MAX <
> 100000000000000000.  The limits of long long are irrelevant here.
> 
> Andreas.
> 
> -- 
> Andreas Schwab, SuSE Labs, schwab@suse.de
> SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
> Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread
* RE: gcc 3.3: long long bug?
@ 2003-04-07 14:44 Lev Assinovsky
  0 siblings, 0 replies; 33+ messages in thread
From: Lev Assinovsky @ 2003-04-07 14:44 UTC (permalink / raw)
  To: A.R. Ashok Kumar, Anders Adland; +Cc: Andreas Schwab, Eric Botcazou, gcc-help

How comes it works fine in gcc 3.2?

----
Lev Assinovsky
Aelita Software Corporation
O&S Core Division, Programmer
ICQ# 165072909


> -----Original Message-----
> From: A.R. Ashok Kumar [mailto:ashokar@sankhya.com]
> Sent: Monday, April 07, 2003 6:37 PM
> To: Anders Adland
> Cc: Andreas Schwab; Eric Botcazou; Lev Assinovsky; 
> gcc-help@gcc.gnu.org
> Subject: Re: gcc 3.3: long long bug?
> 
> 
> Hi,
> 
> On 7 Apr 2003, Anders [ISO-8859-1] Ådland wrote:
> 
> > I don't know anything about C standards, but why do we have 
> to add the
> > 'LL' suffix? Is it giving any additional information to the 
> compiler?
> 
>   If you didn't specify 'L' or 'LL' suffix, then gcc will consider it
>   as "integer" type (4 bytes). 
> 
> -AshokA-
> 
> > On Mon, 2003-04-07 at 15:07, A.R. Ashok Kumar wrote:
> > > Hi,
> > > 
> > > > |>    You can check the size of "long long" type in 
> your system, by printing
> > > > |>    sizeof(long long). 
> > > > 
> > > > On my system sizeof(long) is 8.
> > > 
> > >   Since 8 bytes are too small to hold 35-bit numbers, the 
> error occurred.
> > > 
> > >   Please use 'LL' suffix, to solve the problem.
> > > 
> > >    i.e  const long long n = 34359738368LL;
> > > 
> > > - AshokA -
> > > 
> > 
> > 
> 
> 
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2003-04-07 20:22 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-07 11:29 gcc 3.3: long long bug? Lev Assinovsky
2003-04-07 11:42 ` Eric Botcazou
2003-04-07 12:15   ` Andreas Schwab
2003-04-07 12:31     ` A.R. Ashok Kumar
2003-04-07 12:42       ` Andreas Schwab
2003-04-07 13:09         ` A.R. Ashok Kumar
2003-04-07 13:13           ` Andreas Schwab
2003-04-07 13:18             ` A.R. Ashok Kumar
2003-04-07 14:28           ` Anders Ådland
2003-04-07 14:36             ` Andreas Schwab
2003-04-07 14:38             ` A.R. Ashok Kumar
2003-04-07 14:56               ` Andreas Schwab
2003-04-07 13:01     ` John Love-Jensen
2003-04-07 13:11       ` Andreas Schwab
2003-04-07 13:11     ` Eric Botcazou
2003-04-07 13:16       ` Andreas Schwab
2003-04-07 13:08 Lev Assinovsky
2003-04-07 13:13 ` A.R. Ashok Kumar
2003-04-07 13:13 Lev Assinovsky
2003-04-07 13:43 ` A.R. Ashok Kumar
2003-04-07 13:40   ` John Love-Jensen
2003-04-07 14:12     ` A.R. Ashok Kumar
2003-04-07 14:04   ` Andreas Schwab
2003-04-07 13:15 Lev Assinovsky
2003-04-07 13:33 Lev Assinovsky
2003-04-07 13:43 Lev Assinovsky
2003-04-07 13:36 ` A.R. Ashok Kumar
2003-04-07 20:22 ` Ben Davis
2003-04-07 13:43 Lev Assinovsky
2003-04-07 14:12 ` Andreas Schwab
2003-04-07 14:41 Lev Assinovsky
2003-04-07 14:58 ` Andreas Schwab
2003-04-07 14:44 Lev Assinovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).