[cfe-dev] Type qualifiers

John McCall rjmccall at apple.com
Wed Aug 1 23:51:46 PDT 2012


On Aug 1, 2012, at 11:24 PM, Umesh Kalappa wrote:
> gcc pop up with the  error for the below sample 
> 
> [root at insiscssgs06 ~]# cat  test.c
> int main()
> {
>  int i ;
>  int a[ const i =10] ;
>  while (i <10)
>  a[i++]=i;
> }
> 
> [root at insiscssgs06 ~]# gcc  test.c
> test.c: In function âmainâ:
> test.c:4: error: static or type qualifiers in non-parameter array declarator
> 
> [root at insiscssgs06 ~]# gcc  --version
> gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
> 
> But ,The same compiles with clang 
> 
> [root at insiscssgs06 ~]# clang --version
> clang version 3.2 (trunk) (llvm/trunk 158444)
> Target: i386-pc-linux-gnu
> Thread model: posix
> [root at insiscssgs06 ~]# clang test.c
> 
> According to c99 in the section 6.7 the clang is right.Before i report a bug in the  GCC .Any thoughts or inputs or suggestions ???

This is definitely our bug, not GCC's:

C99 6.7.6.2p1:
  The optional type qualifiers and the keyword static shall appear only in a declaration of a function parameter with an array type, and then only in the outermost array type derivation.

So please file your bug at http://llvm.org/bugs/ rather than gnu.org. :)

This should be simple for us to check and fix.

John.



More information about the cfe-dev mailing list