From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/03 Message-ID: <611pr5$8vd$1@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 277498988 References: <610rbh$58f@news-rocq.inria.fr> Organization: Comp Sci, RMIT University, Melbourne, Australia. NNTP-Posting-User: ok Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec harley@pauillac.inria.fr (Robert Harley) writes: >Well sure, if for some strange reason you wanted to turn a >pointer-pointer-pointer into a pointer-pointer, C allows it via a cast. >But why on earth would you want to do that? I can only assume that >you meant 'double ** triMat' in which case assign it: > double const*const*const constTriMat; > constTriMat = triMat; >or pass it as an argument: > double myFunc(double const*const*const bla); > myFunc(triMat); Doesn't work. There's an illuminating discussion in the rationale of the POSIX.1 standard about why they didn't chuck a const or two into the prototypes for the exec() functions. "Specifying two levels of const-qualification for the argv[] and envp[] parameters for the exec functions may seem to be the natural choice, given that these functions do not modify either the array of pointers or the characters to which the function (sic) points, but this would disallow existing correct code. Instead, only the array of pointers is noted as constant. The table of assignment compatibility for dst = src, derived from the C standard, summarizes the compatibility: dst const char * const char src char *[] char *[] const [] * const [] char *[] VALID VALID const char *[] VALID VALID char * const [] VALID const char * const [] VALID " Entries not marked VALID are not valid at all. THIS is Nick Maclaren's point. Given char **triMat; the declaration double const * const * const constTriMat = triMat; is simply illegal. It's illegal because there are plausible implementations where it won't work. Anyone who thinks it does clearly hasn't bothered to read the standard, or even a good textbook (not there are many). >Whereas your beloved Fortran checks that the user's assumptions about >lack of aliasing are correct, perhaps? Yes, there are indeed static checkers available for Fortran that will check such assumptions. I have not used any myself, but I am aware of two. -- John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL. Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.