This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c/5304: gcc-20011231 generates incorrect divmod code for chars



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]