Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!cfctech!teemc!ka3ovk!ki4pv!cdis-1!tanner From: tanner@cdis-1.uucp (Dr. T. Andrews) Newsgroups: comp.lang.c Subject: Re: sizeof a struc field Message-ID: <7685@cdis-1.uucp> Date: 20 Oct 89 14:53:39 GMT References: <7710@microsoft.UUCP> <11316@smoke.BRL.MIL> Organization: Society to Save the Sand Gnat Lines: 24 ) I said that dereferencing a null pointer CONSTANT was meaningless, ) and it is EXACTLY the kind of thing I want compilers to check for ) me at compile time. There is no service being rendered by a compiler, ) when it is in a position to detect a usage error at compile time, ) silently proceeding to generate code that may blow up at run time. I would suggest that, since sizeof() generates an integral constant, that any compiler which generated code which blew up for sizeof(((type *)0)->member) /* cited construct */ has a basic flaw. So far, we have heard that dereferencing a null pointer is garbage (but we aren't dereferencing one), and that null pointer CONSTANTS shouldn't be dereferenced (we still aren't dereferencing one), and that an explicitly cast null pointer lacks type information (a claim which is hard to swallow). What we have not heard is a convincing explanation of why the cited construct should be considered harmful. No excuse for an implementation that might blow up on it has been given. Further, no useful alternative has (to date) shown up. -- Cutting half of passenger service | {bpa,uunet}!cdin-1!cdis-1!tanner Mulroney: "cold froze our brains" | {attctc gatech!uflorida}!ki4pv!cdis-1!tanner