This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/46657] New: Didn't check an array's boundary


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46657

           Summary: Didn't check an array's boundary
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: schuh.robert@gmail.com


Hello,

I'm running Ubuntu 10.10 64-bit on my Dell laptop with Intel Core 2 Duo. I am
using Ubuntu's gcc 4.4.5 compiler. I have found which might be a bug while
compiling and running a simple program. The bug is that the compiler didn't do
an array boundary check, as a short program below will show that. 

#include<stdio.h>
int main() {
    char ary[5];

    ary[0] = 'a';
    ary[1] = 'b';
    ary[2] = 'c';
    ary[3] = 'd';
    ary[4] = 'e';
    ary[5] = 'f';    
    ary[6] = '\n';
    ary[7] = 'a';
    ary[8] = '\n';

    printf("%s", ary);

    return 0;
}

The gcc compiler just happily compiled it without any warning. As you can see
that I declared an array to hold 5 chars but I went over the limit by adding
more elements to the array. The compiler accepted that and compiled it. This
could be a serious bug as the compiler was supposed to check for that kind
violations, as I can remember. 

Thanks,
Robert


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]