c9h@psuecl.bitnet (12/08/89)
There is a generic problem with zero-sized arrays that everyone seems to be ignoring: I see nowhere a definition of what *order* C is to store variables in. Even the use a previously mentioned as being valid -- using it to change the size of a malloc'd structure to allocate space for an array of the size needed -- would be affected by this. Am I overlooking something, or is storage order actually undefined? -- - Charles Martin Hannum II "Klein bottle for sale ... inquire within." (That's Charles to you!) "To life immortal!" c9h@psuecl.{bitnet,psu.edu} "No noozzzz izzz netzzzsnoozzzzz..." cmh117@psuvm.{bitnet,psu.edu} "Mem'ry, all alone in the moonlight ..."
chris@mimsy.umd.edu (Chris Torek) (12/09/89)
In article <70691@psuecl.bitnet> c9h@psuecl.bitnet writes: >Am I overlooking something, or is storage order actually undefined? Storage allocation order in general is left to the implementation, but some things are specified. In particular, structure members must be allocated in order, possibly leaving gaps. That is, a compiler cannot take something like struct foo { int a; char b; double c; char d; }; and `rearrange' it to the order c/a/b/d, even if that would cause the structure to fit in nearly half as much space. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris
henry@utzoo.uucp (Henry Spencer) (12/09/89)
In article <70691@psuecl.bitnet> c9h@psuecl.bitnet writes: >There is a generic problem with zero-sized arrays that everyone seems to >be ignoring: I see nowhere a definition of what *order* C is to store >variables in... Although this is mostly true, ANSI C does constrain members within a struct to be in ascending order. -- 1233 EST, Dec 7, 1972: | Henry Spencer at U of Toronto Zoology last ship sails for the Moon. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu