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

From: Marcel Moolenaar <marcel_at_xcllnt.net>
Date: Sat, 6 Sep 2003 02:46:14 -0700
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
Received on Sat Sep 06 2003 - 00:46:35 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:21 UTC