On Sun, Aug 04, 2024 at 06:40:14PM GMT, Alejandro Colomar wrote: > > The last > > case should return a non-constant. > > The last case [*] is only allowed in prototypes. How should we get the > non-constant value? It's just another way to say [], isn't it? > > > If you reuse the sizeof code, it should be mostly correct, but > > maybe the last case needs to be revisted. In the following > > examples > > > > void foo(char (*a)[3][*], int (*x)[__lengthof__(*a)]); > > void bar(char (*a)[*][3], int (*x)[__lengthof__(*a)]); > > > > the array '*x' should be a regular fixed size array in foo > > but a VLA in 'bar'. > > In the function prototype, it seems to be completely ignoring > __lengthof__, just as it ignores any expression, so I don't know if it's > working (I could try to print some debugging values to stderr from the > compiler, if we care about it).
Huh, no, my bad. It must be using the lengthof value. It needs to match pointers to arrays of a given size. I'll test this. > > $ cat muecker.h > void foo(char (*a)[3][*], int (*x)[__lengthof__(*a)]); > void bar(char (*a)[*][3], int (*x)[__lengthof__(*a)]); > void f(char (*a)[3][*], int (*x)[sizeof(*a)]); > void b(char (*a)[*][3], int (*x)[sizeof(*a)]); > $ /opt/local/gnu/gcc/lengthof/bin/gcc muecker.h -S > $ > > I assume the code above is not reaching my code. -- <https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature