Newsgroups: | comp.arch,comp.compilers |
From: | stripes@uunet.uu.net (Josh Osborne) |
Keywords: | optimize |
Organization: | UUNET Technologies, Inc. (Earth offices) |
References: | 94-10-108 94-10-141 |
Date: | Thu, 27 Oct 1994 04:49:52 GMT |
Andy Glew <glew@ichips.intel.com> wrote:
[...]
>I am aware of the K&R rule that structure elements be in increasing
>order of address. But, since the contiguity requirement has been
>dropped, and since different machines have different padding rules,
>what value does the address ordering rule have? Even network header
>code cannot be written portably using structures to access data
>structures placed in memory from DMA devices.
>
>I believe that C's rules about data structure organization are
>obsolete. Certainly, they are not in the ken of the usual programmer
>using C or C++. Why not permit compilers to do such "illegal" data
>structure reorganizations, bringing the performance gains Lebeck and
>Wood describes to the standard application?
Have you ever seen code like this:
struct type1 {
int a;
char *b;
char *c;
};
struct type2 {
int a;
float b;
char * c;
};
union foo {
type1 t1;
type2 t2;
};
Then code looks at "foo.t1.a" to decide if foo is of type t1 or t2?
I beleve this sort of thing is at least somewhat common. I also think
Xlib does it (with the event structure). This may also be legal without
the union, but I find that distasteful (of corse I'm not real happy with
the union either...).
>I suggest that this be considered by future X3J11 ANSI C standards (if
>any such revisions are forthcoming).
Remember to deal with union's.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.