by 0x09 · 12y ago · 0 comments
> Beguiled by the example of PL/I, early C did not tie structure pointers firmly to the structures they pointed to, and permitted programmers to write pointer->member almost without regard to the type of pointer; such an expression was taken uncritically as a reference to a region of memory designated by the pointer, while the member name specified only an offset and a type.
However, I stand corrected in two regards. The first is that as of gcc 4.6+, the sed example the author provided is no longer allowed even if the structs are unnamed. (I was testing with gcc 3.4.) I verified that gcc 3.4 would happily allow me to use the provided sed example as long as I removed the names from the structs.
Second, the C11 standard specifically does not allow for the sed example provided because the structs in the unions contain duplicate members.
I had seen reasoning that hinted at what you're saying in one of the comments posted on the author's blog entry.
Regardless, thanks for encouraging me to dig deeper.