http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54950



             Bug #: 54950

           Summary: Incorrect 32-bit moltiplication on m32c target

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: critical

          Priority: P3

         Component: c

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: m.gala...@centrosistemi.it





m32c-elf-gcc (GCC) 4.7.2 hosted on Windows XP.



This simple program:



/*********** BEGIN ************/

#include <stdio.h>



void multiply(unsigned char byte)

{

  printf("%ld\n", 1000000L * byte);

}



main()

{

  multiply(2);

  return 0;

}

/**************** END ************/



produces the correct result (2000000) only when compiled with -O0:



m32c-elf-gcc -msim -mcpu=m32c -O0 -omul32.out mul32.c

m32c-elf-run mul32.out



If I compile with -O1, -O2, -O3 or -Os I get 33920, which is 2000000 truncated

to 16-bit.

Reply via email to