Article View: gnu.gcc.help
Article #52649gcc-2.2.2 enum treated as unsigned
From: Eric Fifer
Date: Sun, 21 Jun 1992 13:34
Date: Sun, 21 Jun 1992 13:34
42 lines
1749 bytes
1749 bytes
I ran into a problem with olvwm3.2 and gcc-2.2.2 on a SS2 running SunOS
4.1.1. The following code at the end of vdmPerformAction in virtual.c
is causing problems when an offset is negative:
deltas.delta_x = vdm->offsetX +
((a - ACTION_GOTO_1) % vdm->columns) * dw;
deltas.delta_y = vdm->offsetY +
((a - ACTION_GOTO_1) / vdm->columns) * dh;
This short program demonstrates the same problem:
enum action { ACTION_GOTO_1, ACTION_GOTO_5 };
main()
{
double x, y;
int offsetX = -1;
int offsetY = -1;
int columns = 5;
int dw = 1152;
int dh = 900;
enum action a = ACTION_GOTO_5;
x = offsetX + ((a - ACTION_GOTO_1) % columns) * dw;
y = offsetY + ((a - ACTION_GOTO_1) / columns) * dh;
printf("x=%f y=%f\n", x, y);
}
For some reason the expression (a - ACTION_GOTO_1) is being treated
as an unsigned int. Casting the expression to int fixes the problem,
but this doesn't seem right.
Any help would be appreciated.
--
Eric Fifer
Salomon Brothers Asia Limited
Urbannet Otemachi Bldg, 18th Fl
2-2, Otemachi 2-chome | Internet: egf@sbi.com
Chiyoda-ku, Tokyo 100, Japan | UUCP: uunet!sbi!egf
Technical Details
Message-ID:
<1389@hera.Sbi.Com>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!spool.mu.edu!olivea!sgigate!psinntp!psinntp!internet!sbi!zeuswtc!hera!hera.sbi.comShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,8cbacb0b8033c7b5,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-06-21 04:54:50 PST Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!spool.mu.edu!olivea!sgigate!psinntp!psinntp!internet!sbi!zeuswtc!hera!hera.sbi.com From: egf@hera.sbi.com (Eric Fifer) Newsgroups: gnu.gcc.help Subject: gcc-2.2.2 enum treated as unsigned Message-ID: <1389@hera.Sbi.Com> Date: 21 Jun 92 13:34:40 GMT Article-I.D.: hera.1389 Sender: egf@hera.Sbi.Com Organization: Salomon Brothers, NY Lines: 42