public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: pbarada@mail.wm.sps.mot.com
To: gcc-gnats@gcc.gnu.org
Subject: c/5304: gcc-20011231 generates incorrect divmod code for chars
Date: Mon, 07 Jan 2002 12:26:00 -0000	[thread overview]
Message-ID: <200201072016.g07KGjd18069@hyper.wm.sps.mot.com> (raw)


>Number:         5304
>Category:       c
>Synopsis:       gcc-20011231 generates incorrect divmod code for chars
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 07 12:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Peter Barada
>Release:        3.1 20011231 (experimental)
>Organization:
Motorola, Inc.
>Environment:
System: Linux hyper.wm.sps.mot.com 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home/pbarada/work/cvs-wavemark/cross-linux-tools/gcc-20011231/configure --target=i686-linux --prefix=/tmp/crap8/ --enable-languages=c --with-local-prefix=/tmp/crap/i686-linux
>Description:
The divmod code produces truncated magic numbers (at least for i686)
when the value of the divmod is a char.  If the value is a short/int,
the result is calculated in int, and is correct.

The result of the code given is:
Huh? modulus is 141
Huh? quotient is 63

Which is *quite* wrong.

>How-To-Repeat:
typedef unsigned char ufix8;

ufix8 val = 7;
ufix8 expected = 1;

main(int argc, char *argv[])
{
  ufix8 result;
  int err = 0;

  result = val % 6;
  if (result != expected) {
    printf("Huh? modulus is %d\n", result);
    err++;
  }

  result = val / 6;
  if (result != expected) {
    printf("Huh? quotient is %d\n", result);
    err++;
  }    
  exit(err?-1:0);
}
>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-01-07 20:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-07 12:26 pbarada [this message]
2002-02-01  8:01 jakub
2002-02-19  4:04 jakub

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=200201072016.g07KGjd18069@hyper.wm.sps.mot.com \
    --to=pbarada@mail.wm.sps.mot.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: link
Be 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).