Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!think!yale!cmcl2!lanl!lambda!jlg From: jlg@lambda.UUCP (Jim Giles) Newsgroups: comp.lang.misc Subject: Re: Relationship between C and C++ Message-ID: <14286@lambda.UUCP> Date: 23 Mar 90 01:02:41 GMT References: <1990Mar22.181947.27026@maths.nott.ac.uk> Lines: 22 From article <1990Mar22.181947.27026@maths.nott.ac.uk>, by anw@maths.nott.ac.uk (Dr A. N. Walker): > [...] Yes, aliassing is a problem for optimising > compilers, and if used casually is a problem for program-proving; but > exactly the same problems arise with arrays, [...] NO! The same problem does NOT arise with arrays. Two different arrays are two different objects. Period. Two different pointers might both point to the SAME object. This behaviour of pointers is not only legal in all languages, it is encouraged. Yes, it is true that most implementations don't check arrays to make sure that no aliasing has occurred. But, the implementor can optimize array usage with a clear conscience - after all, only illegal programs get broken. Pointer usage cannot be optimized this way. Further, arrays CAN be tested to make sure illegal aliasing has not occurred - it costs about the same as bounds checking. Pointers cannot be tested in this manner because it is _LEGAL_ for them to be aliased! [I know - still beating the same dead horse. This issue NEVER seems to go away.] J. Giles