Path: utzoo!attcan!uunet!nih-csl!lhc!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: [m]allocation question Message-ID: <13946@smoke.BRL.MIL> Date: 27 Sep 90 21:56:16 GMT References: Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 11 In article ghoti+@andrew.cmu.edu (Adam Stoller) writes: > t = (struct node *) malloc(sizeof *t); >Isn't *t garbage at the time the sizeof is performed - isn't this >[almost?] de-referencing a NULL pointer. We went through this about a year ago in a different guise. The outcome of that discussion was that, since the argument to sizeof is NOT evaluated, there is no attempt to access through that pointer, and only the type (not the value) of the hypothetical result is relevant. Thus sizeof(*t) is obliged to work even if t contains a garbage value.