From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C8E7C3895FC9; Fri, 21 Jun 2024 00:15:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8E7C3895FC9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718928938; bh=49EHzsEOKcXGDGbXdlS7HLAdUZcO3cKWRwAOK/WrGx4=; h=From:To:Subject:Date:From; b=KyVRUSskHeQq3vcYixeKLgMqjRcCwfKr8vj2K3VIlz6rt/Pua/w/mqm44GnUszSUE wi3v5XbjZPQjpnZrdByCej9lWim5pD/gpf4v52kC95TRsVjBjK5VJRfD+lfL2uV4CY lXWirfcnmDz0Umz5OFbxFDEoPOJAD07+dj0EkjT0= From: "Curt.Blank at curtronics dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/115570] New: array subscript 'long unsigned int[0]' is partly outside array bounds of 'unsigned char[4]' Date: Fri, 21 Jun 2024 00:15:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Curt.Blank at curtronics dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115570 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 year= s. 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 =3D 0; if (! bSwapEndian) { cValue[0] =3D Buffer[aParam4] & 0xff; cValue[1] =3D Buffer[aParam3] & 0xff; cValue[2] =3D Buffer[aParam2] & 0xff; cValue[3] =3D Buffer[aParam1] & 0xff; } else { cValue[0] =3D Buffer[aParam1] & 0xff; cValue[1] =3D Buffer[aParam2] & 0xff; cValue[2] =3D Buffer[aParam3] & 0xff; cValue[3] =3D Buffer[aParam4] & 0xff; } value =3D (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=3D] 1906 | if (bVerbose) fprintf(stderr, "szCvrtLong %12lu 0x%02x%02x%02x%02x\n",*value & 0xffffffff,cValue[3],cValue[2],cValue[1],cValue[0]); |=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ^~~~~~ 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=3D] 1908 | return(*value & 0xffffffff); | ^~~~~~ comm.c:1890:19: note: object 'cValue' of size 4 1890 | unsigned char cValue[4]; | ^~~~~~=