>Submitter-Id:  net
>Originator:    Steven Young
>Organization:  n/a
>Confidential:  no
>Synopsis:      gcc allows negatively-sized arrays
>Severity:      non-critical
>Priority:      low
>Category:      c
>Class:         accepts-illegal
>Release:       gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
>Environment:
System: Linux pc1 2.6.20-15-generic #2 SMP Sun Apr 15 07:36:31 UTC 2007 i686 
GNU/Linux
Architecture: i686
        
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v 
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr 
--enable-shared --with-system-zlib --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --enable-nls 
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
>Description:
    By using an integer variable as the size of an array to be 
    initialized on the stack, you can trick gcc into accepting
    and trying to create a negatively-sized array.  The assembly
    it generates in such a case seems to indicate it really thinks
    it has a negatively-sized array.
>How-To-Repeat:
    #include <stdio.h>

    int main(int argc, char **argv) {
        int x = -2;
        int y[x];

        printf("%d\n", sizeof(y));
    }

    This will output -8.

>Fix:
    I don't know.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to