Am Dienstag, dem 06.08.2024 um 16:12 +0200 schrieb Alejandro Colomar:
> Hi Martin,
>
> On Tue, Aug 06, 2024 at 03:37:13PM GMT, Martin Uecker wrote:
> > Am Dienstag, dem 06.08.2024 um 14:22 +0200 schrieb Alejandro Colomar:
> > > Hi!
> > >
> > > - The tests seem to work as expected if I compile them manually, and
> > > run (the one that should be run) as a normal program. The one that
> > > should not be run also gives the expected diagnostics.
> > > Can anyone give advice of why it's not running well under the test
> > > suite?
> >
> > What is the output? You get an additional warning / error.
>
> $ /opt/local/gnu/gcc/lengthof/bin/gcc
> gcc/testsuite/gcc.dg/lengthof-compile.c
> gcc/testsuite/gcc.dg/lengthof-compile.c: In function ‘incomplete’:
> gcc/testsuite/gcc.dg/lengthof-compile.c:10:19: error: invalid
> application of ‘lengthof’ to incomplete type ‘int[]’
> 10 | n = __lengthof__(x); /* { dg-error "incomplete" } */
> | ^
> gcc/testsuite/gcc.dg/lengthof-compile.c:14:19: error: invalid
> application of ‘lengthof’ to type ‘int *’
> 14 | n = __lengthof__(p); /* { dg-error "invalid" } */
> | ^
> gcc/testsuite/gcc.dg/lengthof-compile.c: In function ‘fam’:
> gcc/testsuite/gcc.dg/lengthof-compile.c:26:19: error: invalid
> application of ‘lengthof’ to incomplete type ‘int[]’
> 26 | n = __lengthof__(s.fam); /* { dg-error "incomplete" } */
> | ^
> gcc/testsuite/gcc.dg/lengthof-compile.c: In function ‘func’:
> gcc/testsuite/gcc.dg/lengthof-compile.c:41:20: error: passing argument
> 3 of ‘fix_fix’ from incompatible pointer type [-Wincompatible-pointer-types]
> 41 | fix_fix(5, &c35, &i5); /* { dg-error
> "incompatible-pointer-types" } */
> | ^~~
> | |
> | int (*)[5]
> gcc/testsuite/gcc.dg/lengthof-compile.c:29:44: note: expected ‘int
> (*)[3]’ but argument is of type ‘int (*)[5]’
> 29 | void fix_fix(int i, char (*a)[3][5], int
> (*x)[__lengthof__(*a)]);
> | ~~~~~~^~~~~~~~~~~~~~~~~~~~
> gcc/testsuite/gcc.dg/lengthof-compile.c:44:20: error: passing argument
> 3 of ‘fix_var’ from incompatible pointer type [-Wincompatible-pointer-types]
> 44 | fix_var(5, &c35, &i5); /* { dg-error
> "incompatible-pointer-types" } */
> | ^~~
> | |
> | int (*)[5]
> gcc/testsuite/gcc.dg/lengthof-compile.c:30:44: note: expected ‘int
> (*)[3]’ but argument is of type ‘int (*)[5]’
> 30 | void fix_var(int i, char (*a)[3][i], int
> (*x)[__lengthof__(*a)]);
> | ~~~~~~^~~~~~~~~~~~~~~~~~~~
> gcc/testsuite/gcc.dg/lengthof-compile.c:47:20: error: passing argument
> 3 of ‘fix_uns’ from incompatible pointer type [-Wincompatible-pointer-types]
> 47 | fix_uns(5, &c35, &i5); /* { dg-error
> "incompatible-pointer-types" } */
> | ^~~
> | |
> | int (*)[5]
> gcc/testsuite/gcc.dg/lengthof-compile.c:31:44: note: expected ‘int
> (*)[3]’ but argument is of type ‘int (*)[5]’
> 31 | void fix_uns(int i, char (*a)[3][*], int
> (*x)[__lengthof__(*a)]);
> | ~~~~~~^~~~~~~~~~~~~~~~~~~~
> $ /opt/local/gnu/gcc/lengthof/bin/gcc
> gcc/testsuite/gcc.dg/lengthof-compile.c |& grep ' error: '
> gcc/testsuite/gcc.dg/lengthof-compile.c:10:19: error: invalid
> application of ‘lengthof’ to incomplete type ‘int[]’
> gcc/testsuite/gcc.dg/lengthof-compile.c:14:19: error: invalid
> application of ‘lengthof’ to type ‘int *’
> gcc/testsuite/gcc.dg/lengthof-compile.c:26:19: error: invalid
> application of ‘lengthof’ to incomplete type ‘int[]’
> gcc/testsuite/gcc.dg/lengthof-compile.c:41:20: error: passing argument
> 3 of ‘fix_fix’ from incompatible pointer type [-Wincompatible-pointer-types]
> gcc/testsuite/gcc.dg/lengthof-compile.c:44:20: error: passing argument
> 3 of ‘fix_var’ from incompatible pointer type [-Wincompatible-pointer-types]
> gcc/testsuite/gcc.dg/lengthof-compile.c:47:20: error: passing argument
> 3 of ‘fix_uns’ from incompatible pointer type [-Wincompatible-pointer-types]
> $ /opt/local/gnu/gcc/lengthof/bin/gcc
> gcc/testsuite/gcc.dg/lengthof-compile.c |& grep ' error: ' | wc -l
> 6
>
> I count 6, which is what I expect:
>
> $ grep dg-error gcc/testsuite/gcc.dg/lengthof-compile.c
> n = __lengthof__(x); /* { dg-error "incomplete" } */
> n = __lengthof__(p); /* { dg-error "invalid" } */
> n = __lengthof__(s.fam); /* { dg-error "incomplete" } */
> fix_fix(5, &c35, &i5); /* { dg-error "incompatible-pointer-types" } */
> fix_var(5, &c35, &i5); /* { dg-error "incompatible-pointer-types" } */
> fix_uns(5, &c35, &i5); /* { dg-error "incompatible-pointer-types" } */
> $ grep dg-error gcc/testsuite/gcc.dg/lengthof-compile.c | wc -l
> 6
>
> When running `make check -j24 -Orecurse |& tee log`, this is what I see:
>
> FAIL: gcc.dg/lengthof-compile.c (test for excess errors)
>
> Is there any way to see more details?
See gcc/testsuite/gcc/gcc.log
There are also *.sum files which you can diff against a build
without your patch to see whether there are any regressions.
>
> > > - I don't like the fact that [*][n] is internally implemented exactly
> > > like [0][n], which makes them indistinguishable. All other cases of
> > > [0] return a constent expression of value 0, but [0][n] must return a
> > > variable 0, to keep support for [*][n].
> > > Could you please change the way [*][n] (and thus [*]) is represented
> > > internally so that it can be differentiated from [0]?
> > > Do you have in mind any other way that would be a viable
> > > implementation of [*] that would allow distinguishing [0][n] and
> > > [*][n]? Maybe making it to have one node instead of zero and mark
> > > that node specially?
> >
> > The C++ frontend encodes zero-sized arrays using a range of [0,-1].
> > I have a half-finished patch which implements this for the C FE.
>
> Thanks! I guess your patch will be merged before mine, so please ping
> me when that happens so I update mine for it.
Not sure about this...
>
> BTW, do you allow me to use Co-developed-by: you?
ok,
Martin
>
> Have a lovely day!
> Alex
>