🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1750

Re: [m]allocation question

#1750
From: Henry Spencer
Date: Wed, 26 Sep 1990 18:03
12 lines
933 bytes
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
Technical Details
Message-ID: <1990Sep26.180332.8342@zoo.toronto.edu>
Path: arc1-ca.pugleaf.net!utzoo!henry
References: <UaxqffS00Vtq8akksB@andrew.cmu.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!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