This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: unknown bound: array error.
- To: Ingo Krabbe <i dot krabbe at dokom dot net>
- Subject: Re: unknown bound: array error.
- From: "Mark J. Turick" <mturick at mrburns dot npt dot nuwc dot navy dot mil>
- Date: Tue, 10 Jul 2001 18:05:14 -0400
- CC: gcc help <gcc-help at gcc dot gnu dot org>
- Organization: Logicon, Inc.
- References: <Pine.LNX.4.33.0107100017580.29059-100000@flathead.burg.de>
Thats curious that your test application compiled with gcc3.1. I
grabbed the
latest cvs snapshot and tried again without any better luck. I think
I traced
my problem to gcc/gcc/cp/decl.c: lines 11957-11974.
/* [dcl.fct]/6, parameter types cannot contain pointers
(references) to arrays of unknown bound. */
tree t = TREE_TYPE (type);
int ptr = TYPE_PTR_P (type);
while (1)
{
if (TYPE_PTR_P (t))
ptr = 1;
else if (TREE_CODE (t) != ARRAY_TYPE)
break;
else if (!TYPE_DOMAIN (t))
break;
t = TREE_TYPE (t);
}
if (TREE_CODE (t) == ARRAY_TYPE)
cp_error ("parameter `%D' includes %s to array of
unknown
bound `%T'",
decl, ptr ? "pointer" : "reference", t);
Maybe I'm too dense, but there has to be a lot of code around that
breaks
this rule. After all, its hard to see the difference between a
'**var' and
'*var[]', just look at all the code still around with "main( int
argc, char
*argv[])" and/or "main( int argc, char **argv)" as an obvious
example.
I guess we're stuck using gcc 2.95....
Ingo Krabbe wrote:
> On Mon, 9 Jul 2001, Mark J. Turick wrote:
>
> >
> > I have a large amount of legacy code for a project that we support
> > on
> > various unix platforms. Some of the internal structures are defined
> > as:
> >
> > typedef struct {
> > int xpos;
> > int ypos;
> > } XYCoordStruct, (*XYCoordPtr)[];
> >
> Ok it seems to be another standart problem. While Solaris 8 and
> GCC Compilers try to behave as standart compilers many others try to
> compile code that programmers thought of nice looking code. Its a kind of
> philosophy. I'm not involved in the devlopment of GCC, but I think it goes
> in the right direction, thinking about the future.
> By the way. I don't get this error with gcc 3.1 (which comes from
> a cvs checkout).
> typedef struct
> {
> int xpos;
> int ypos;
> } XYCoordStruct, *(XYCoordPtr)[];
>
> int libdReturnVCoords (
> int id_index, int time, int npts,
> XYCoordPtr rpts, int *nearest );
>
> int main( argc, argv )
> int argc;
> char** argv;
> {
> int x;
> XYCoordStruct* a;
> libdReturnVCoords( 10, 5, x, &a, &x );
> return 0;
> }
>
> compiles fine, though complaining about missing libdReturnVCoords at the
> linker stage of course. But I cannot declare a Variable to be of type
> XYCoordPtr of course!
> XYCoordPtr b;
> gives a "array size missing in `b'" error.