Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/kern



> Date: Sun, 2 Aug 2020 16:04:15 +0200
> From: Kamil Rytarowski <kamil%netbsd.org@localhost>
> 
> On 02.08.2020 15:57, Taylor R Campbell wrote:
> > But it sounds like the original motivation is that it triggered
> > -Wvla...which frankly strikes me as a compiler bug since there's
> > obviously no actual VLA created in sizeof; as far as I can tell
> > there's no semantic difference between sizeof(device_t[n]) and
> > sizeof(device_t) * n.
> 
> This is not true:

Which part of what I said are you claiming is not true, and what are
you illustrating with the example program below?

It seems to illustrate that sizeof(int[argc]) does exactly what one
would expect it to do -- return the size of an argc-length array of
ints, just like sizeof(int) * argc does.



> #include <stdio.h>
> 
> int
> main(int argc, char **argv)
> {
>         printf("sizeof = %zu\n", sizeof(int[argc]));
>         return 0;
> }
> 
> $ ./a.out
> 
> sizeof = 4
> $ ./a.out 12 3
> sizeof = 12
> $ ./a.out 12 3 45 6
> sizeof = 20


Home | Main Index | Thread Index | Old Index