This is the mail archive of the 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]

Bug in gcc-20011231

Given the testfile:

#include <stdio.h>

typedef unsigned char ufix8;

ufix8 val = 1;
ufix8 expected = 1;

main(int argc, char *argv[])
  ufix8 result;

  result = val % 6;
  if (result != expected) {
    fprintf(stderr,"Huh? modulus is %d\n", result);

and gcc:

[pbarada: /tmp] > /tmp/crap8/bin/i686-linux-gcc -v
Reading specs from /tmp/crap8/bin/../lib/gcc-lib/i686-linux/3.1/specs
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
Thread model: single
gcc version 3.1 20011231 (experimental)

The results are:

[pbarada: /tmp] > /tmp/crap8/bin/i686-linux-gcc -O -o test2 test2.c
[pbarada: /tmp] > ./test2
Huh? modulus is 135

The code generated is:

	pushl	%ebp
	movl	%esp, %ebp
	subl	$24, %esp
	andl	$-16, %esp
	movzbl	val, %edx
	movzbw	%dl, %ax
	imull	$-85, %eax, %eax
	shrl	$8, %eax
	movb	%al, %cl
	shrb	$2, %cl
	movb	%cl, %al
	addb	%al, %al
	addb	%cl, %al
	addb	%al, %al
	movb	%dl, %cl
	subb	%al, %cl
	cmpb	expected, %cl

Which looks bizzare.  I tried moduluses of 3, 5, 10, all of which
produced incorrect results.

Any ideas?

Peter Barada                         
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)

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