https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115570
Bug ID: 115570 Summary: array subscript 'long unsigned int[0]' is partly outside array bounds of 'unsigned char[4]' Product: gcc Version: 13.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: Curt.Blank at curtronics dot com Target Milestone: --- I just ran into a compile error on code that has been just fine for 18 years. The only reason I'm compiling it is just to be sure on a new computer/Linux install. With gcc 4.8.3 I do not get the warnings, with gcc 13.3.0 I get the warnings shown below the code below. The char string being converted is hex, data returned from a solar inverter. And like I said it's been fine and I suspect the program will run fine just cannot fully test it yet until data collect is moved to this new server. *-------------------------------------------------------------------------- szCvrtLong Converts a 4 char string to a long. ----------------------------------------------------------------------------*/ unsigned long szCvrtLong(char *Buffer) { unsigned char cValue[4]; unsigned long *value = 0; if (! bSwapEndian) { cValue[0] = Buffer[aParam4] & 0xff; cValue[1] = Buffer[aParam3] & 0xff; cValue[2] = Buffer[aParam2] & 0xff; cValue[3] = Buffer[aParam1] & 0xff; } else { cValue[0] = Buffer[aParam1] & 0xff; cValue[1] = Buffer[aParam2] & 0xff; cValue[2] = Buffer[aParam3] & 0xff; cValue[3] = Buffer[aParam4] & 0xff; } value = (unsigned long *)cValue; if (bVerbose) fprintf(stderr, "szCvrtLong %12lu 0x%02x%02x%02x%02x\n",*value & 0xffffffff,cValue[3],cValue[2],cValue[1],cValue[0]); return(*value & 0xffffffff); } ----------- comm.c: In function 'szCvrtLong.constprop': comm.c:1906:77: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'unsigned char[4]' [-Warray-bounds=] 1906 | if (bVerbose) fprintf(stderr, "szCvrtLong %12lu 0x%02x%02x%02x%02x\n",*value & 0xffffffff,cValue[3],cValue[2],cValue[1],cValue[0]); | ^~~~~~ comm.c:1890:19: note: object 'cValue' of size 4 1890 | unsigned char cValue[4]; | ^~~~~~ comm.c:1908:12: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'unsigned char[4]' [-Warray-bounds=] 1908 | return(*value & 0xffffffff); | ^~~~~~ comm.c:1890:19: note: object 'cValue' of size 4 1890 | unsigned char cValue[4]; | ^~~~~~