Path: utzoo!attcan!uunet!lll-winken!ames!haven!purdue!decwrl!thundr.dec.com!minow From: minow@thundr.dec.com (Repent! Godot is coming soon! Repent!) Newsgroups: comp.sys.mac.programmer Subject: re: serious code generation bug in Lightspeed C Message-ID: <8901131605.AA09908@decwrl.dec.com> Date: 13 Jan 89 19:01:00 GMT Organization: Digital Equipment Corporation Lines: 29 Tim Maroney (sun!hoptoad!tim) point out that Think C evaluates the left-hand side of (*h)->p = NewPtr(size) before the right-hand side (and consequently, the dereferenced *h points to stale data). This is explicitly permitted by C, both under existing practice and in the Draft Ansi Standard. The only exception to this would be if h is defined as "volatile" (which, it in fact is). Think C doesn't appear to support volatile yet (and doesn't claim to be Ansi compatible). It would certainly be reasonable for Think to put a note in their manuals warning programmers of this problem. Until then, the cautious programmer would be well advised to write { Ptr temp = NewPtr(size); (*h)->p = temp; } Which should operate correctly. Thanks, by the way, for pointing this out -- I'm going to go through a huge pile of code to see if I've been caught by the same problem. Martin Minow minow%thundr.dec@decwrl.dec.com