[5942] in Athena Bugs
Saber msg: v2.1 (4/24/89 m1-238-4 vax Unix 4042 0)
daemon@ATHENA.MIT.EDU (lerman@ATHENA.MIT.EDU)
Tue Sep 4 16:40:43 1990
From: lerman@ATHENA.MIT.EDU
Date: Tue, 4 Sep 90 16:40:32 -0400
To: bugs@ATHENA.MIT.EDU
Does Saber-C handle mixed arithmetic according to the ANSI standard? When
I run a program that adds a float with an int using the gcc compiler, I
get a result which is a float. When I execute the same program using
Saber-C, I get a result which is a double. This happens even when I
set the ANSI option in Saber-C.
The specific program is as follows:
#include <stdio.h>
main()
{
float f;
int i;
i = 5;
f = 3.0;
printf("Size of float is %d\n", sizeof(float));
printf("Size of int is %d\n", sizeof(int));
printf("Size of int + float is %d\n", sizeof(f + i));
printf("Size of float + double is %d\n", sizeof(f+ 7.0));
printf("Size of int + double is %d\n", sizeof(i + 7.0));
}
The output from the Free Software Foundation gcc compiler from this program
is as follows:
Size of float is 4
Size of int is 4
Size of int + float is 4
Size of float + double is 8
Size of int + double is 8
However, the output from Saber-C is:
Size of float is 4
Size of int is 4
Size of int + float is 8
Size of float + double is 8
Size of int + double is 8
Program exiting with return status = 0.
The ANSI C specification implies that the gcc compiler is correct and that
the Saber-C is wrong.
Steven R. Lerman
(lerman@athena.mit.edu)