This is the mail archive of the gcc-help@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]

How to fix 'array subscript is above array bounds' ?


Hi

We normally use gcc 4.1.2 to compile our C++ code, but I am now experimenting with gcc 4.4.6.

I am getting a compiler warning with 4.4.6, that I did not see with 4.1.2, and I donât understand how to fix it.

Hereâs the code:

myFunc(int& a_mcsIndex)
{
    const unsigned SPS_MCS_TABLE_SIZE = 4;
    const int SPS_MCS_TABLE_MCS[SPS_MCS_TABLE_SIZE] = { 19, 12, 8, 6};

    for ( unsigned ind=0; ind<SPS_MCS_TABLE_SIZE; ind++ )
   {
       a_mcsIndex = SPS_MCS_TABLE_MCS[ind-1];                â== warning

Warning: array subscript is above array bounds

How can I fix this warning please?

Best regards

David


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