public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40099]  New: 64bit constants
@ 2009-05-11  2:06 Andrey dot Martchovsky at gmail dot com
  2009-05-11  2:07 ` [Bug c++/40099] " Andrey dot Martchovsky at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andrey dot Martchovsky at gmail dot com @ 2009-05-11  2:06 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

The following code produces

andrey@tiny:~/Documents/Thesis/TIA/pll$ gcc tst.c 
tst.c:2: warning: integer constant is too large for ‘long’ type
andrey@tiny:~/Documents/Thesis/TIA/pll$ g++ tst.c 
tst.c:2: error: integer constant is too large for ‘long’ type


1:#include <stdio.h>
2:long long int tst = 8000000000;
3:int main(){
4:      printf("sizeof(long long int)=%d\n",sizeof(long long int));
5:      printf("tst=%lld\n",tst);
6:      return 0;
7:}


-- 
           Summary: 64bit constants
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Andrey dot Martchovsky at gmail dot com
GCC target triplet: g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40099


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

* [Bug c++/40099] 64bit constants
  2009-05-11  2:06 [Bug c++/40099] New: 64bit constants Andrey dot Martchovsky at gmail dot com
@ 2009-05-11  2:07 ` Andrey dot Martchovsky at gmail dot com
  2009-05-11  6:09 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andrey dot Martchovsky at gmail dot com @ 2009-05-11  2:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from Andrey dot Martchovsky at gmail dot com  2009-05-11 02:07 -------
*** Bug 40098 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40099


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

* [Bug c++/40099] 64bit constants
  2009-05-11  2:06 [Bug c++/40099] New: 64bit constants Andrey dot Martchovsky at gmail dot com
  2009-05-11  2:07 ` [Bug c++/40099] " Andrey dot Martchovsky at gmail dot com
@ 2009-05-11  6:09 ` jakub at gcc dot gnu dot org
  2009-05-11 18:22 ` Andrey dot Martchovsky at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-05-11  6:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2009-05-11 06:08 -------
Why is that a problem? C and C++ are different languages.  Compiling with g++
means you are compiling the C code as C++ (see documentation).


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40099


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

* [Bug c++/40099] 64bit constants
  2009-05-11  2:06 [Bug c++/40099] New: 64bit constants Andrey dot Martchovsky at gmail dot com
  2009-05-11  2:07 ` [Bug c++/40099] " Andrey dot Martchovsky at gmail dot com
  2009-05-11  6:09 ` jakub at gcc dot gnu dot org
@ 2009-05-11 18:22 ` Andrey dot Martchovsky at gmail dot com
  2009-05-11 18:28 ` pinskia at gcc dot gnu dot org
  2009-05-11 19:05 ` Andrey dot Martchovsky at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: Andrey dot Martchovsky at gmail dot com @ 2009-05-11 18:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from Andrey dot Martchovsky at gmail dot com  2009-05-11 18:22 -------
(In reply to comment #2)
> Why is that a problem? C and C++ are different languages.  Compiling with g++
> means you are compiling the C code as C++ (see documentation).
> 

My problem is that the error for 64bit ints in C++ shows up only under the x86
implementation of g++,
compiling the same code under x86_64 does not result in any errors.

Btw, the documentation for C++ suggests to use either int64_t or long long, for
64bit integers, and with either, I cannot define a constant that is greater
than 2^31-1. Therefore this is a bug, as the compiler DOES recognize the
declared variable to be 64 bit wide, and DOES all the 64bit arithmetic properly
(add,sub,mul,div,mod,shift ...), but DOES NOT recognize the variable to be
64bits in the initial parsing.


-- 

Andrey dot Martchovsky at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40099


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

* [Bug c++/40099] 64bit constants
  2009-05-11  2:06 [Bug c++/40099] New: 64bit constants Andrey dot Martchovsky at gmail dot com
                   ` (2 preceding siblings ...)
  2009-05-11 18:22 ` Andrey dot Martchovsky at gmail dot com
@ 2009-05-11 18:28 ` pinskia at gcc dot gnu dot org
  2009-05-11 19:05 ` Andrey dot Martchovsky at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-05-11 18:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2009-05-11 18:27 -------
For C++98 and C90, integer constants can only fit into the long type. You need
to use LL if you want a 64bit integer constant.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40099


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

* [Bug c++/40099] 64bit constants
  2009-05-11  2:06 [Bug c++/40099] New: 64bit constants Andrey dot Martchovsky at gmail dot com
                   ` (3 preceding siblings ...)
  2009-05-11 18:28 ` pinskia at gcc dot gnu dot org
@ 2009-05-11 19:05 ` Andrey dot Martchovsky at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: Andrey dot Martchovsky at gmail dot com @ 2009-05-11 19:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from Andrey dot Martchovsky at gmail dot com  2009-05-11 19:04 -------
(In reply to comment #4)
> For C++98 and C90, integer constants can only fit into the long type. You need
> to use LL if you want a 64bit integer constant.
> 

Thank you for clarifying this.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40099


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

end of thread, other threads:[~2009-05-11 19:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-11  2:06 [Bug c++/40099] New: 64bit constants Andrey dot Martchovsky at gmail dot com
2009-05-11  2:07 ` [Bug c++/40099] " Andrey dot Martchovsky at gmail dot com
2009-05-11  6:09 ` jakub at gcc dot gnu dot org
2009-05-11 18:22 ` Andrey dot Martchovsky at gmail dot com
2009-05-11 18:28 ` pinskia at gcc dot gnu dot org
2009-05-11 19:05 ` Andrey dot Martchovsky at gmail dot com

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).