Hi Joseph,

On Tue, Aug 06, 2024 at 08:50:19PM GMT, Joseph Myers wrote:
> static int f(), f2();
> int a[10][10];
> int x;
> 
> void
> g()
> {
>   __lengthof__ (a[f()]); // Should be valid that f is not defined.
>   int b[x][x];
>   __lengthof__ (b[f2()]); // Should be invalid that f2 is not defined.
> }

Thanks!  That makes sense.  It works as you expect, I think.

        alx@debian:~/tmp/gcc$ cat ext.c 
        static int f(), f2();
        int a[10][10];
        int x;

        int
        main(void)
        {
                int b[x][x];

                __lengthof__(a[f()]);
                __lengthof__(b[f2()]);
        }
        alx@debian:~/tmp/gcc$ /opt/local/gnu/gcc/lengthof/bin/gcc ext.c 
        ext.c:1:17: warning: ‘f2’ used but never defined
            1 | static int f(), f2();
              |                 ^~
        /usr/bin/ld: /tmp/ccqlTYWo.o: in function `main':
        ext.c:(.text+0xe0): undefined reference to `f2'
        collect2: error: ld returned 1 exit status

Cheers,
Alex

-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature

Reply via email to