Re: C Help Magic Square

From: Tim Rentsch (txr_at_alumnus.caltech.edu)
Date: 11/02/04


Date: 01 Nov 2004 20:41:54 -0800

Jack Klein <jackklein@spamcop.net> writes:

> On Sun, 31 Oct 2004 21:07:29 -0500, "winnerpl" <winnerpl@hotmail.com>
> wrote in comp.lang.c:
>
> > void fill_square(int[][], int);
>
>> [some snippage]
>
> In any case, the prototype above is not valid C, it is a syntax error.
> There is no such thing as a function array parameter with more than
> one empty '[ ]' pair. If your compiler accepts this, it is either not
> a C compiler or you are not invoking it to operate in standard C
> conforming mode.

Both a prototype and a function definition with an 'int[][]' type were
accepted by 'gcc -(ansi|std=c99) -pedantic' -- some warnings, but no
errors, and certainly no syntax errors. Is gcc in error here?
Or does the standard actually allow this?

Incidentally, the meaning assigned seems to be the same as though
it were like this:

    int f( int (*)[] ); /* or int f( int [][] ); */

    int f( int (*x)[] ){ /* or int f( int x[][] ){ */
        return (*x)[0];
    }

    extern int a[];

    int main(){
        return f( &a ) == 0;
    }

Of course, I'm making no claim that code like this is sensible.
Only asking if it's legal.



Relevant Pages

  • Syntax ???
    ... '85 Standard conforming compiler. ... *is* a syntax error. ... If a vendor documents that they only support 16M of Working-Storage, ...
    (comp.lang.cobol)
  • Re: TR 24731 approved
    ... I worked and worked and this syntax error would never go away. ... It's part of the language, and has been for 17 years. ... Because it's an important issue in achieving a consensus standard. ... I have no means of coercing you to ...
    (comp.std.c)
  • Re: Syntax (was: Perfrom Thru
    ... If "source violates the rules of the Standard" ... Then "source must get a syntax error" ... Bill Klein ...
    (comp.lang.cobol)
  • Re: Syntax (was: Perfrom Thru
    ... It isn't about source violating the rules of the standard, ... Doc's objection is that a diagnostic from a compiler should state ... whether the problem is a compiler limitation or it is a syntax error, ... If source code violates the syntax for COBOL as laid down in the ...
    (comp.lang.cobol)
  • Re: Perfrom Thru
    ... Rick Smith wrote: ... >> implementation is not conforming to the standard. ... >As I mentioned previously, below, in my experience the compiler ... >a syntax error requiring syntactic correction, ...
    (comp.lang.cobol)