Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!brunix!gvr From: gvr@cs.brown.edu (George V. Reilly) Newsgroups: comp.lang.c Subject: Lint question Message-ID: <32699@brunix.UUCP> Date: 14 Mar 90 03:34:34 GMT Sender: news@brunix.UUCP Reply-To: gvr@cs.brown.edu (George V. Reilly) Organization: Brown University Department of Computer Science Lines: 46 Given the following code, lint complains: point.c(33): warning: evaluation order for ``dx'' undefined The complaint turns out to be caused by the subexpression (dx *= dx) Surely, the parenthesization and comma operators make the whole expression well defined? ========================================================================= typedef struct { int x, y; } Point; /* ---------------------------------------------------------------------- * * closest_point(): Return the index of point |pt| within * point-table |table| of size |n|. Return -1 on error. * * ---------------------------------------------------------------------- */ int closest_point(pt, table, n) Point pt; Point table[]; int n; { register int min = MAXINT, dist, dx, dy, result = -1, x, y; x = pt.x; y = pt.y; while (--n >= 0) { /* Ugly but efficient test for proximity */ if (((dx = table[n].x - x), ((dx *= dx) < min)) && ((dy = table[n].y - y), ((dist = dx + dy*dy) < min))) { result = n; min = dist; } } return (result); } ========================================================================= ________________ George V. Reilly gvr@cs.brown.edu uunet!brunix!gvr gvr@browncs.bitnet Box 1910, Brown U, Prov, RI 02912