Bugzilla – Bug 151488
micq-0.5.0.4-3:array subscript out of range
Last modified: 2006-02-17 09:28:34 UTC
I just tried to compile package micq-0.5.0.4-3 with the Intel C compiler. It said contact.c(1240): warning #175: subscript out of range The source code is else if (HAS_CAP (cont->caps, CAP_TRILL_CRYPT | CAP_TRILL_2)) but #define HAS_CAP(caps,cap) (((caps)[cap / 32]) & (1UL << (cap % 32))) and CAP_TRILL_CRYPT has the value 18 and the CAP_TRILL_2 has a value of 19. So making the macro subsitution else if (((cont->caps)[ CAP_TRILL_CRYPT | CAP_TRILL_2 / 32]) & (1UL << (CAP_TRILL_CRYPT | CAP_TRILL_2 % 32))) I just checked the C precedence table. Both / and % are higher than | so the macro expansion is the same as else if (((cont->caps)[ CAP_TRILL_CRYPT | (CAP_TRILL_2 / 32)]) & (1UL << (CAP_TRILL_CRYPT | (CAP_TRILL_2 % 32)))) hence the compiler complaining. Suggest modify the macro definition #define HAS_CAP(caps,cap) (((caps)[(cap) / 32]) & (1UL << ((cap) % 32))) Note the extra () around the uses of cap to ensure correct evaluation.
Good catch! Good explanation! I'll fix this. Thanks a lot!
Created attachment 68968 [details] Fixes for macros
fixed for 10.1 Beta > 4.