Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ut-sally!im4u!rutgers!labrea!rocky!andy From: andy@rocky.STANFORD.EDU (Andy Freeman) Newsgroups: comp.lang.c Subject: swap - every definition so far is wrong Message-ID: <560@rocky.STANFORD.EDU> Date: Sun, 6-Sep-87 18:04:06 EDT Article-I.D.: rocky.560 Posted: Sun Sep 6 18:04:06 1987 Date-Received: Sun, 6-Sep-87 22:43:11 EDT References: <557@rocky.STANFORD.EDU> <1880@sol.ARPA> <109@umigw.MIAMI.EDU> <1109@bsu-cs.UUCP> Reply-To: andy@rocky.UUCP (Andy Freeman) Organization: Stanford University Computer Science Department Lines: 17 The pointer definitions do the right thing with swap( i, a[i] ), as long as i isn't a register variable. (Rahul Dhesi mentioned this.) They also fail on swap( a, b ) when a and b are arrays. (Steve Emmerson, steve@umigw.MIAMI.EDU, caught this one; I hadn't thought of it.) These problems come from c; cpp causes one additional problem. Swap should work no matter what names are used outside the definition. swap( __t, __x ) should work; all of the proposed definitions fail if the argument has the "wrong" name. -andy -- Andy Freeman UUCP: {arpa gateways, decwrl, sun, hplabs, rutgers}!sushi.stanford.edu!andy ARPA: andy@sushi.stanford.edu (415) 329-1718/723-3088 home/cubicle