in the following, += and *= are miscompiled because an optimisation
is applied that only works if the left-hand side of the assignment
is floating point.
cat <<'!' >pt.c
typedef struct Point {int x, y;} Point;
#define PI 3.1415626535
double cos(double), sin(double);
int print(char*, ...);
Point
circlept(Point c, int r, int degrees)
{
double rad;
rad = (double) degrees * PI/180.0;
c.x += cos(rad)*r;
c.x *= cos(rad)*r;
c.y -= sin(rad)*r;
print("circlerad %d %d\n", c.x, c.y);
return c;
}
!
|