Question about genassym, locore.s and 0-sized arrays(showstopper for an icc compiled kernel)

Marcel Moolenaar marcel at xcllnt.net
Sat Sep 6 02:46:35 PDT 2003


On Sat, Sep 06, 2003 at 10:57:52AM +0200, Alexander Leidinger wrote:
> 
> ---snip---
> % <marcel.c   
> #include <stdio.h>
> 
> struct foo {
>         int tag;
>         char obj[];
> };
> 
> int main(void) {
>         struct foo bar;
> 
>         printf("%d\n", sizeof(struct foo));
>         printf("%d\n", sizeof(bar));
> 
>         return 0;
> }
> 
> % ./a.out     
> 4
> 4
> ---snip---

The compiler seems to behave correctly WRT C99. However, when
presented with code that uses extensions the compiler behaves
inconsistently or erratically. If the compiler cannot do any-
thing useful with zero-sized arrays, it should reject them
completely. Only then can one reasonably fall back on C99 to
explain the behaviour of the compiler. However, since the
compiler accepts zero-sized arrays, it is already in violation
with C99 and one cannot use C99 as a basis to explain the
any behaviour of the compiler in the context of the non-compliant
construct. The creation of single-element array instead of
the declared zero-element array is downright broken.

My $0.02

-- 
 Marcel Moolenaar	  USPA: A-39004		 marcel at xcllnt.net


More information about the freebsd-current mailing list