Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: forbidden? unnecessary? (was: variable-length struct hack) Message-ID: <11778@smoke.BRL.MIL> Date: 9 Dec 89 08:57:32 GMT References: <448@longway.TIC.COM> <450@longway.TIC.COM> <15364@haddock.ima.isc.com> <4749@fireball.cs.vu.nl> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 16 In article <4749@fireball.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >But couldn't an conforming implementation FORBID the (T *) cast?! No, a conforming implementation is obliged to accept a strictly conforming application. It cannot impose its own additional constraints beyond those spelled out in the Standard. > strcpy(p->name = (char *)p + sizeof(T), s); >If this method is used, copying the struct pointed to by p won't have strange >effects, as long as *p isn't free()d. Regarding the struct dirent example >I'd call that an improvement. Hardly. The declared object T does not contain all of the information; the "name" data lies outside the T object. This is as bad as the case that Dennis objected to so far as its usability goes (apart from linguistic correctness issues).