public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/15506] New: wrong cast from long to long long
@ 2004-05-18 16:17 ken dot tsukahara at tmt-d dot co dot jp
  2004-05-18 16:25 ` [Bug c/15506] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: ken dot tsukahara at tmt-d dot co dot jp @ 2004-05-18 16:17 UTC (permalink / raw)
  To: gcc-bugs

on x86 family(32bit) Linux
RedHat9 : GCC 3.2.2, 3.2.3
SUSE9 : GCC 3.3.1, 3.4.1

A long long value which is casted from a long value (< 0) seems to be wrong.

$ cat longlong.c

#include <stdio.h>
int main(int argc, char **argv)
{
    long long     ll = 0xc0000000;
    unsigned long ul = 0xc0000000;
    long          sl = 0xc0000000;

    printf("long long : 0x%llx\n", ll);
    printf("u_long    : 0x%lx\n",  ul);
    printf("long      : 0x%lx\n",  sl);
    printf("u_long -> long long : 0x%llx\n", (long long)ul);
    printf("long   -> long long : 0x%llx\n", (long long)sl);

    return 0;
}

$ cc -o longlong longlong.c
$ ./longlong
long long : 0xc0000000
u_long    : 0xc0000000
long      : 0xc0000000
u_long -> long long : 0xc0000000
long   -> long long : 0xffffffffc0000000

-- 
           Summary: wrong cast from long to long long
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P1
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ken dot tsukahara at tmt-d dot co dot jp
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c/15506] wrong cast from long to long long
  2004-05-18 16:17 [Bug c/15506] New: wrong cast from long to long long ken dot tsukahara at tmt-d dot co dot jp
@ 2004-05-18 16:25 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-18 16:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-18 01:54 -------
Invalid read about sign extensions and twos complement numbers.

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


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


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

end of thread, other threads:[~2004-05-18  1:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-18 16:17 [Bug c/15506] New: wrong cast from long to long long ken dot tsukahara at tmt-d dot co dot jp
2004-05-18 16:25 ` [Bug c/15506] " pinskia at gcc dot gnu dot org

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