public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: ksteege@dsrnet.com To: gcc-gnats@gcc.gnu.org Subject: c/5430: possible gcc 2.96 error in simple arithmetic statement w/ 16 & 32 bit values Date: Fri, 18 Jan 2002 18:36:00 -0000 [thread overview] Message-ID: <20020119023429.7025.qmail@sources.redhat.com> (raw) >Number: 5430 >Category: c >Synopsis: possible gcc 2.96 error in simple arithmetic statement w/ 16 & 32 bit values >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Jan 18 18:36:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Kevin Steege >Release: GCC 2.96 >Organization: >Environment: Red Had Linux 7.1 >Description: Not sure if this is a true compiler bug or not, but the following problem occurred when we migrated to Linux RedHat 7.1 which came with gcc 2.96. The problem did not occur with RedHat 6.2 which came with gcc 2.91. The code line : Result = (((my_ushort + 2) * 2) - sizeof (my_8_struct) - 4) / 2; where Result is a unsigned 32 bit value, my_ushort is an unsigned 16 bit value set to 924, and my_8_struct is an 8 byte structure Produces the correct result with gcc 2.91 : (((my_ushort + 2) * 2) - sizeof (my_8_struct) - 4) / 2 = 920 = 0x398 But an incorrect value with gcc 2.96 : (((my_ushort + 2) * 2) - sizeof (my_8_struct) - 4) / 2 = 2147484568 = 0x80000398 Obviously there is a problem with the way the compiler casts the values between 16 bit and 32 bit integers, or at least with the way I believe the compiler should cast the values. >How-To-Repeat: Compile attached file mytest.c & run : gcc mytest.c ./a.out >Fix: The sample program contains several similar lines which work around the problem. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-01-19 2:36 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-01-18 18:36 ksteege [this message] 2002-04-23 2:35 rth 2002-04-23 16:31 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=20020119023429.7025.qmail@sources.redhat.com \ --to=ksteege@dsrnet.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).