Jump to content
Eternal Lands Official Forums
Sign in to follow this  
Florian

dds.c: warning: array subscript is above array bounds

Recommended Posts

my brand new gcc 4.4 complains about dds.c

 

dds.c: In function 'unpack_dxt_interpolated_alpha':

dds.c:147: warning: array subscript is above array bounds

dds.c:147: warning: array subscript is above array bounds

dds.c: In function 'unpack_ati1':

dds.c:147: warning: array subscript is above array bounds

dds.c:147: warning: array subscript is above array bounds

dds.c: In function 'unpack_ati2':

dds.c:147: warning: array subscript is above array bounds

dds.c:147: warning: array subscript is above array bounds

dds.c:147: warning: array subscript is above array bounds

dds.c:147: warning: array subscript is above array bounds

dds.c: In function 'unpack_dxt5':

dds.c:147: warning: array subscript is above array bounds

dds.c:147: warning: array subscript is above array bounds

Share this post


Link to post
Share on other sites

Hi!

 

I checked the code again (because I wrote it), but i can't see any problem there. Seems like your gcc makes a mistake. :)

i	idx0	idx1	idx0 + 1
0	0	0	-
1	0	3	-
2	0	6	1
3	1	1	-
4	1	4	-
5	1	7	2
6	2	2	-
7	2	5	-
8	3	0	-
9	3	3	-
10	3	6	4
11	4	1	-
12	4	4	-
13	4	7	5
14	5	2	-
15	5	5	-

Share this post


Link to post
Share on other sites

typedef struct DXTInterpolatedAlphaBlock
{
Uint8 m_alphas[2];
Uint8 m_indices[6];
} DXTInterpolatedAlphaBlock;

 

block->m_indices[idx0 + 1]

 

idx0 reaches 5, +1 makes 6 --> ArrayOutOfBoundsException

Share this post


Link to post
Share on other sites

That's why I added the last row. idx0 +1 is not always used, only when idx1 is greater than 5. That are the 4 values in the last row. If idx1 is 5 or less, idx0 + 1 is not used as index

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×