Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!elroy.jpl.nasa.gov!jato!jdickson From: jdickson@jato.jpl.nasa.gov (Jeff Dickson) Newsgroups: comp.sys.amiga.programmer Subject: Re: Is this valid C? Message-ID: <1991May10.211545.14302@jato.jpl.nasa.gov> Date: 10 May 91 21:15:45 GMT References: <1991May5.222328.16225@csis.dit.csiro.au> <616@lysator.liu.se> <38542@ditka.Chicago.COM> Reply-To: jdickson@jato.Jpl.Nasa.Gov (Jeff Dickson) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 32 In article <38542@ditka.Chicago.COM> comeau@csanta.attmail.com (Greg Comeau) writes: >In article <616@lysator.liu.se> zap@lysator.liu.se (Zap Andersson) writes: >>struct foop *p; >>struct foop { int a; char *b }; >>main() { p->a = 39; /* Will complier barf here? */ } > >There will be a no barf since at the ->a, foop is no longer an incomplete >type. It is not a problem. > >- Greg >-- > Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418 > Producers of Comeau C++ 2.1 > Here:attmail.com!csanta!comeau / BIX:comeau / CIS:72331,3421 > Voice:718-945-0009 / Fax:718-441-2310 Perhaps the compiler wouldn't barf, but the program would. "*p" is declared as a pointer to a structure of type "foop". Structure "foop" is defined so the compiler would know at what offset each member occurred at, but "*p" is not pointing to an allocated instance of it. Now if you had: struct foop { int a; char *b } p; ...then p.a = 39; ...would be valid. -jeff