flaps@dgp.toronto.edu (Alan J Rosenthal) (05/03/90)
henley@motcid.UUCP (Aaron Henley) writes: >I think people should and in many cases must be aware of how their compiler >allocates memory for structures, what happens when you typecast a word from a >memory location starting at a point that isn't word aligned, etc... These and >many other usages of C are ambiguously defined. This is completely wrong. These things are UNDEFINED, not at all ambiguous. The following two statements are both unambiguously false: a) dereferencing a misaligned pointer in C dumps core; and b) dereferencing a misaligned pointer in C doesn't dump core. That's what undefined means. It doesn't mean that one of them is true. ajr
raeburn@athena.mit.edu (Ken Raeburn) (05/03/90)
|> henley@motcid.UUCP (Aaron Henley) writes: |> >I think people should and in many cases must be aware of how their compiler |> >allocates memory for structures, what happens when you typecast a word from a |> >memory location starting at a point that isn't word aligned, etc... These and |> >many other usages of C are ambiguously defined. A reasonable statement, except that "ambiguously defined" is perhaps not the technically correct term. In the standard they are undefined, implementation-defined, et cetera. In article <1990May2.150837.946@jarvis.csri.toronto.edu>, flaps@dgp.toronto.edu (Alan J Rosenthal) writes: |> This is completely wrong. These things are UNDEFINED, not at all ambiguous. |> The following two statements are both unambiguously false: |> a) dereferencing a misaligned pointer in C dumps core; and |> b) dereferencing a misaligned pointer in C doesn't dump core. |> That's what undefined means. It doesn't mean that one of them is true. It also does not mean that they are false. It means that you cannot determine (without more information, if at all) the truth of either of them, or even whether "to dump core" will have meaning in a particular context. Aaron was referring to "the implementation of C on the programmer's commonly used platform", not "C in the abstract, as defined by the standard". This seems clear from his mention of "how their compiler allocates memory for structures".... In the specific case, either one of the statements you suggest could be true. He was suggesting that programmers find out what the implementation-defined results are.