Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!samsung!cs.utexas.edu!uwm.edu!bionet!agate!shelby!neon!pescadero.Stanford.EDU!philip From: philip@pescadero.Stanford.EDU (Philip Machanick) Newsgroups: comp.lang.c++ Subject: Re: Please help me... Keywords: Tracer, Help, Destruct Message-ID: <1991Jan10.223143.5752@Neon.Stanford.EDU> Date: 10 Jan 91 22:31:43 GMT References: <7748@castle.ed.ac.uk> <7749@castle.ed.ac.uk> Sender: news@Neon.Stanford.EDU (USENET News System) Reply-To: philip@pescadero.stanford.edu Distribution: comp Organization: Computer Science Department, Stanford University Lines: 33 In article <7749@castle.ed.ac.uk>, eanv20@castle.ed.ac.uk (John Woods) writes: |> Ahah. Could it be that only _named_ local objects may not be destructed before |> they exit their scope? Must read my ARM more carefully. Sorry for wasting |> everybody's bandwidth and time. However, this would render the example |> function void f() ARM 3.5 (p22) incorrect. Errata list, anyone? I tried your example on cfront 2.0, with similar results. Replacing Tracer("foo"); by Tracer a ("foo"); // the name a is not used anywhere else also seemed to give the "expected" behaviour. I've seen a claim that this technique may also be used to implement a lock: { Lock (lock_id); // Lock is a constructor: makes an object which // locks the identified lock and remembers its identity // critical region } // destructor sees that unlock happens at close of scope If the behaviour you report here is typical, this is clearly not a safe alternative to lock(lock_id); // critical region unlock(lock_id); Any clarification of this issue would be useful. (One advantage of introducing a name for the Tracer or Lock object is you no longer get "warning: result of constructor call expression not used" messages; a disadvantage is it obscures the fact that the constructor is used purely for its side-effect.) -- Philip Machanick philip@pescadero.stanford.edu