This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/46657] New: Didn't check an array's boundary
- From: "schuh.robert at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 25 Nov 2010 10:48:48 +0000
- Subject: [Bug c/46657] New: Didn't check an array's boundary
- Auto-submitted: auto-generated
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