c/599: gcc doesn't complain if an array of size 0 is declared.

lml@sasi.com lml@sasi.com
Wed Oct 4 00:26:00 GMT 2000


>Number:         599
>Category:       c
>Synopsis:       gcc doesn't complain if an array of size 0 is declared.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 04 00:26:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Mahendra Ladhe
>Release:        2.95.2
>Organization:
>Environment:
SunOS sund6 5.7 Generic_106541-10 sun4u sparc SUNW,Ultra-250 
>Description:
Following program doesn't produce any compilation error.

main.c
{
 int a[0];
 
 printf("\n a[0] = %d \n", a[0]);
}

The output I get on different SunOS machines is always
5.
>How-To-Repeat:
Just compile the attached file "sample.c" using gcc
(version 2.95.2) on some SunOS machine and run it.
>Fix:
The compiler must not allow an array of size 0 to
be declared.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-unknown-content-type-cfile; name="sample.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="sample.c"

bWFpbigpCnsKICAgaW50IGFbMF07CgogICBwcmludGYoIlxuIGFbMF0gPSAlZCBcbiIsIGFbMF0p
Owp9Cg==


More information about the Gcc-bugs mailing list