🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #28

array of incomplete... a totally *new* question

#28
From: Ronald F. Guilmette
Date: Thu, 29 Oct 1992 10:08
54 lines
2186 bytes
In previous messages, I have asked about the validity of *specifying*
an array of elements whose type is some incomplete type, as in:

	typedef struct incomplete array_type[500];
	struct incomplete { int member; }
	array_type table;

I do not by any means consider that question settled, however I have a
totally separate question now which relates only marginally to that
other issue.

According to one expert, the above code is valid ANSI C because the
incomplete type *does* get completed before the end of the compilation
unit (and before anything about it really needs to be known).

Now, keep that thought in mind.

Also keep in mind that the type `void' is a SPECIAL CASE of an incomplete
type... i.e. one which can NEVER be completed.

Now, somebody please tell me if the following code is valid ANSI C:


		void foobar (void arg[])
		{
		}

Note that it would *definitely* be invalid to simply declare a variable
like:

		extern void variable[];

or even:

		void variable[20];

but in the case of a formal argument which has an *apparent* array type,
that type "decays" into a pointer type somewhere along the line.  Now
the big question is "When does that happen?"

If it happens *before* any check is made to see if the type specification
for the formal parameter is valid, then the above code is valid.  If (on
the other hand) it occurs *after* the general checking for "type validity"
is done for the formal parameter, then the above code is not valid.

Who wants to try answering this question.  Any takers?

-- 

// Ron ("Loose Cannon") Guilmette
// uucp: ...uunet!lupine!segfault!rfg
// New new motto:  Quality control is a state of mind.
//   misc.forsale.computers ad, circa 2007:
//       Used Cray wrist watch for sale; 25 bucks or best offer.
Technical Details
Message-ID: <1992Oct29.100832.27812@netcom.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!rfg

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!umn.edu!csus.edu!netcom.com!rfg
From: rfg@netcom.com (Ronald F. Guilmette)
Subject: array of incomplete... a totally *new* question
Message-ID: <1992Oct29.100832.27812@netcom.com>
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
Date: Thu, 29 Oct 1992 10:08:32 GMT
Lines: 54