Newsgroups: comp.std.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: [m]allocation question
Message-ID: <1990Sep26.180332.8342@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <UaxqffS00Vtq8akksB@andrew.cmu.edu>
Date: Wed, 26 Sep 90 18:03:32 GMT

In article <UaxqffS00Vtq8akksB@andrew.cmu.edu> 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.

No; the operand of a sizeof is never evaluated.  The compiler notes its
type but does not generate code for it.  Beware:  this was not entirely
clear in K&R1 and some old compilers may violate the rule.
-- 
TCP/IP: handling tomorrow's loads today| Henry Spencer at U of Toronto Zoology
OSI: handling yesterday's loads someday|  henry@zoo.toronto.edu   utzoo!henry
