[comp.std.c] Array of functions repost

diamond@csl.sony.co.jp (Norman Diamond) (11/21/89)

This question is also a repost.  It seems to have gotten lost between
kddlabs and the rest of the world, and never got a reply.

Section 3.5.4.3 very carefully prohibits a declaration of the form
  extern int f()[3];  /* function returning array of 3 integers */

Section 3.5.4.2 does not attempt to prohibit a declaration of the form
  extern int f[3]();  /* array of 3 functions, each returning int */
What shall be the meaning of such a declaration?

-- 
Norman Diamond, Sony Corp. (diamond%ws.sony.junet@uunet.uu.net seems to work)
  Should the preceding opinions be caught or     |  James Bond asked his
  killed, the sender will disavow all knowledge  |  ATT rep for a source
  of their activities or whereabouts.            |  licence to "kill".

walter@hpclwjm.HP.COM (Walter Murray) (11/28/89)

Norman Diamond writes:

> I wrote:

>>> Section 3.5.4.2 does not attempt to prohibit a declaration of the form
>>>   extern int f[3]();  /* array of 3 functions, each returning int */
>>> What shall be the meaning of such a declaration?

> In article <12570033@hpclwjm.HP.COM> walter@hpclwjm.HP.COM (Walter Murray) writes:

>>Behavior is undefined because it's an erroneous program construct.
>>Section 3.1.2.5 disallows arrays of functions.

> OK, I have read section 3.1.2.5 three more times.  Where does it
> disallow arrays of functions?  Page number and line number please.

From the December 7, 1988, dpANS:

Page 24, lines 23-24:

   "An array type describes a contiguously allocated nonempty set of
   objects with a particular member object type, called the element
   type."

The key word is "object".  A function is not an object.

Page 23, lines 27-30:

   "Types are partitioned into object types (types that describe
   objects), function types (types that describe functions), and
   incomplete types (types that describe objects but lack information
   needed to determine their sizes)."

Walter Murray
---