This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/14788] New: Subtracting a double from a short gives incorrect result
- From: "rick at glentng dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Mar 2004 21:52:09 -0000
- Subject: [Bug c/14788] New: Subtracting a double from a short gives incorrect result
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
As this is the first bug I have reported in GCC please bear with me - I hope I
have provided all the information you need. This has been confirmed as being a
bug by Eric Botcazou when I originally emailed this to gcc-bugs@gcc.gnu.org
This program needs no header files:
extern int printf (__const char *__restrict __format, ...) ;
int main()
{
short ss;
short fortyk = 40000;
printf("Integer Subtraction\n");
ss = fortyk;
printf("ss = %d\n", ss);
ss = ss - 10000;
printf("ss = %d\n", ss);
printf("Real Subtraction\n");
ss = fortyk;
printf("ss = %d\n", ss);
ss = ss - 10000.0;
printf("ss = %d\n", ss);
return(0);
}
Results are:
> Integer Subtraction
> DDN = -25536
> DDN = 30000
> Real Subtraction
> DDN = -25536
> DDN = -32768
Results should be:
> Integer Subtraction
> DDN = -25536
> DDN = 30000
> Real Subtraction
> DDN = -25536
> DDN = 30000
gcc -v tells me:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/u
sr/share/info --enable-shared --enable-threads=posix --disable-checking --disabl
e-libunwind-exceptions --with-system-zlib --enable-__cxa_atexit --host=i386-redh
at-linux
Thread model: posix
gcc version 3.3.3 20040311 (Red Hat Linux 3.3.3-3)
My GCC was downloaded as a binary - I did not build it.
Regards,
Rick Murphy
--
Summary: Subtracting a double from a short gives incorrect result
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rick at glentng dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: Sorry don't understand the question
GCC host triplet: Redhat 9, Linux 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003
i686 i6
GCC target triplet: Redhat 9, Linux 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003
i686 i6
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14788