See bug #505071. Attached preprocessed source fails to build with -Wall -Werror -O2: pmac /home/dwmw2 $ gcc -c -o sip-sec-ntlm.o sip-sec-ntlm.i -Wall -Werror -O2 cc1: warnings being treated as errors sip-sec-ntlm.c: In function ‘purple_ntlm_gen_authenticate’: sip-sec-ntlm.c:509: error: array subscript is above array bounds gcc version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC) As observed in bug #505071, phrasing the pointer arithmetic slightly differently makes it work fine. The three commented out versions build OK: tmsg->dom_off = sizeof(struct authenticate_message); tmp = ((char*) tmsg) + tmsg->dom_off; // tmp = ((char*) tmsg) + sizeof(struct authenticate_message); // tmp = (char *) (tmsg+1); // tmp = (char *)&tmsg[1];
Sorry, that should be bug #512170
David: You forgot to add the pre-processed file...
Created attachment 355708 [details] test case
FYI: looks like this is not a ppc architecture bug. arm-unknown-linux-gnueabi on Ubuntu reports the same error: <https://launchpad.net/ubuntu/+source/pidgin-sipe/1.5.0-0ubuntu1> <http://launchpadlibrarian.net/29699481/buildlog_ubuntu-karmic-armel.pidgin-sipe_1.5.0-0ubuntu1_FAILEDTOBUILD.txt.gz> cc1: warnings being treated as errors sip-sec-ntlm.c: In function 'sip_sec_init_sec_context__ntlm': sip-sec-ntlm.c:507: error: array subscript is above array bounds make[2]: *** [libsipe_la-sip-sec-ntlm.lo] Error 1
Simplified testcase: struct A { unsigned char a1[8]; unsigned short a2, a3, a4, a5, a6, a7; }; int bar (void *, const char *, int); char *foo (void *, int); char * baz (const char *x, const char *y) { int a = sizeof (struct A) + 2 * (__builtin_strlen (y) + __builtin_strlen (x) + 24) + 16; struct A *b = __builtin_malloc (a); char *c; int d; b->a4 = sizeof (struct A); c = ((char *) b) + b->a4; d = ((char *) b) + a - c; b->a2 = b->a3 = (unsigned short) bar (c, y, d); c += b->a2; d = ((char *) b) + a - c; b->a7 = b->a4 + b->a2; b->a5 = b->a6 = (unsigned short) bar (c, x, d); c = foo (b, a); return c; }
Tracking upstream. As a workaround, either use one of the above mentioned workarounds, or make sure the first field in the struct isn't a char array.
If you drop the 'unsigned' and use just 'char a1[8]' in your test case, in the definition of 'struct A', then it'll occur on architectures where 'char' is signed by default too.