This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Mixed mode arithmetic - GCC 3.3.3-3 bug?
- From: "Richard \(Rick\) Murphy" <rick at glentng dot com>
- To: <gcc-bugs at gcc dot gnu dot org>
- Date: Tue, 30 Mar 2004 00:22:35 +0100
- Subject: Mixed mode arithmetic - GCC 3.3.3-3 bug?
- Reply-to: <rick at glentng dot com>
Hi,
I'm really new to this - hope this is the right place to post this:
Can somebody please explain how this program:
main()
{
short DDN;
short FORTYTHOU = 40000;
printf("Integer Subtraction\n");
DDN = FORTYTHOU;
printf("DDN = %d\n", DDN);
DDN = DDN - 10000;
printf("DDN = %d\n", DDN);
printf("Real Subtraction\n");
DDN = FORTYTHOU;
printf("DDN = %d\n", DDN);
DDN = DDN - 10000.0;
printf("DDN = %d\n", DDN);
}
Gives this result with GCC 3.3.3-3 on RH9 (and also with GCC gcc-3.2.2-5):
Integer Subtraction
DDN = -25536
DDN = 30000
Real Subtraction
DDN = -25536
DDN = -32768
Whereas on Solaris9 with Forte 2 Update 6 compiler I get this (which is what
I would expect):
Integer Subtraction
DDN = -25536
DDN = 30000
Real Subtraction
DDN = -25536
DDN = 30000
Is this a bug in GCC or I am not understanding its behaviour properly ?
Thanks.
--Rick Murphy