ref. to array != ptr

Doug Gwyn gwyn at smoke.brl.mil
Sat Nov 10 16:44:52 AEST 1990


In article <906 at inews.intel.com> bhoughto at cmdnfs.intel.com (Blair P. Houghton) writes:
-In article <14391 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
->In article <894 at inews.intel.com> bhoughto at cmdnfs.intel.com (Blair P. Houghton) writes:
->=  is there anything more explicit stating that the declaration of an
->=externally-defined pointer to Type can not specify an array of Type
->=with the same identifier defined externally?
->Sure.  3.1.2.6:  "All declarations that refer to the same object or
->function shall have compatible type; otherwise, the behavior is undefined."
-Well, yes, I should have mentioned this as part of the inference;
-I'm wondering if there isn't anything to the effect of "don't do
-this" explicitly mentioning array/pointer confusions in multiple
-translation units.

No; taken in conjunction with the words that relate the identifier to
the object (and scope rules, and ...), the above is sufficient.

-The more 3.1.2.6 and the definitions of compatible pointers and
-compatible arrays sink in, though, the clearer the inference
-becomes.  I was just hoping that, as was done for a number of
-other things, there'd be an example of /*RIGHT*/ and /*WRONG*/
-coding.

There are an almost unlimited number of possible examples of stupid
mistakes.  Any decent C tutorial should already fully explain what the
relation is between array and pointer (and what it isn't).  There was
no new, subtle point introduced in the C standard that needed special
explanation, unlike most (or all?) of the other examples.  The usual
X3J11 response to requests for examples like the one you suggest was
"the standard is not a tutorial".



More information about the Comp.std.c mailing list