Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: net.lang.c Subject: Re: op= construction Message-ID: <1355@brl-smoke.ARPA> Date: Sun, 15-Jun-86 01:46:38 EDT Article-I.D.: brl-smok.1355 Posted: Sun Jun 15 01:46:38 1986 Date-Received: Sat, 21-Jun-86 07:38:30 EDT References: <108@mruxe.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 14 In article <108@mruxe.UUCP> cgw@mruxe.UUCP (C Waldman) writes: - In a loop, an array element is incremented, then the array index - is advanced to the next element. I recently coded this with - .... - total[i++] += f; - .... - After a couple of "Memory fault- core dumped" messages, I realized - that i is getting incremented twice. I broke it into two lines and - everything was ok, but I'm wondering why this construction doesn't - work. Either you were incrementing i somewhere else too (e.g. in the for() head), or else your compiler has a bug. The whole point of the op= operators is that the left side is supposed to be evaluated only once.