Mailinglist Archive: opensuse-bugs (8048 mails)

< Previous Next >
[Bug 242277] New: gcc: improved array index checking at run time
  • From: bugzilla_noreply@xxxxxxxxxx
  • Date: Mon, 5 Feb 2007 11:04:25 -0700 (MST)
  • Message-id: <bug-242277-21960@xxxxxxxxxxxxxxxxxxxxxxxxx/>

Summary: gcc: improved array index checking at run time
Product: openSUSE 10.3
Version: unspecified
Platform: All
OS/Version: SuSE Other
Status: NEW
Severity: Enhancement
Priority: P5 - None
Component: Development
AssignedTo: pth@xxxxxxxxxx
ReportedBy: dcb314@xxxxxxxxxxx
QAContact: qa@xxxxxxx

Currently, gcc has no mode to check array indexes
for sanity at run time.

Suggest add a new compiler flag [ -fdebug ? ],
which causes extra code to be generated at run time to check
that the value of an array index is valid.

If the array index in invalid, suggest stop the program
with a suitable error message, including __FILE__ and __LINE__.

So by example,

int array[ 10];

void g( int);

f( int upperLimit)
for (int i = 0; i < upperLimit; ++i)
g( array[ i]);

called by

/* ... */
limit = 20;
/* ... */
f( limit);

then the program would stop at run time with error message

Program a.out: bad array index 10 at line 1234 in file abcdef.c

Configure bugmail:
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

< Previous Next >