🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1116

Is "int (*ptr)[][];" a legal declaration?

#1116
From: Ronald Guilmette
Date: Thu, 22 Mar 1990 16:19
33 lines
1303 bytes
Can someone please clarify the rules for me regarding the following
declarations?

At least two non-ANSI C compilers (i.e. Sun4 & Sequent Symmetry) generate an
error for the declaration of p2 below.  I don't know if that is correct ANSI
behavior however.

Curiously, these non-ANSI C compilers do *not* also complain about the
declaration of p1.

The GNU C compiler (and the g++ compiler) do not issue any error messages
for this code.

AT&T's cfront translator (for C++) issues error messages for the two lines
indicated.  This is also somewhat surprizing.

What should an ANSI C compiler do with this code?



typedef int T;
typedef T array_of_Ts[];
typedef array_of_Ts array_of_array_of_Ts[];	/* error for cfront */

array_of_array_of_Ts *p1;

int (*p2)[][];		/* error for cfront & old C compilers */



// Ron Guilmette (rfg@ics.uci.edu)
// C++ Entomologist
// Motto:  If it sticks, force it.  If it breaks, it needed replacing anyway.
Technical Details
Message-ID: <2608FAF7.25668@paris.ics.uci.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!usc!orion.oac.uci.edu!uci-ics!gateway

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!usc!orion.oac.uci.edu!uci-ics!gateway
From: rfg@paris.ics.uci.edu (Ronald Guilmette)
Newsgroups: comp.std.c
Subject: Is "int (*ptr)[][];" a legal declaration?
Message-ID: <2608FAF7.25668@paris.ics.uci.edu>
Date: 22 Mar 90 16:19:03 GMT
Organization: UC Irvine Department of ICS
Lines: 33