public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: mark.dewing@intel.com To: gcc-gnats@gcc.gnu.org Subject: c/3651: shifting unsigned long on 64 bit machine incorrectly does sign extension Date: Wed, 11 Jul 2001 12:16:00 -0000 [thread overview] Message-ID: <20010711190917.14360.qmail@sourceware.cygnus.com> (raw) >Number: 3651 >Category: c >Synopsis: shifting unsigned long on 64 bit machine incorrectly does sign extension >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Jul 11 12:16:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: mark.dewing@intel.com >Release: gcc version 3.0 20010526 (prerelease) >Organization: >Environment: IA64 Turbolinux >Description: Right shifting an unsigned long should not do a sign extension. This shift on an unsigned long variable works okay, but doing this shift on an expression that has been cast to unsigned long does not. This problem also occurs on Alpha Tru64 with gcc 2.7.2.1 and IRIX with gcc 2.8.1 in 64 bit mode. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="shift-gcc.c" Content-Disposition: inline; filename="shift-gcc.c" #include <stdio.h> main(){ int i,j; unsigned long u,r1,r2; i = -16; j = 1; u = i+j; /* no sign extension upon shift */ r1 = u >> 1; /* sign extension upon shift, but there shouldn't be */ r2 = ( (unsigned long) (i+j) ) >> 1; printf(" r1 = %lx\n",r1); printf(" r2 = %lx\n",r2); }
next reply other threads:[~2001-07-11 12:16 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-07-11 12:16 mark.dewing [this message] 2001-07-17 2:06 Richard Henderson 2002-04-23 2:09 rth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20010711190917.14360.qmail@sourceware.cygnus.com \ --to=mark.dewing@intel.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).